Compare commits

...

45 commits

Author SHA1 Message Date
awalsh128 58600a5c77 Merge branch 'master' of https://github.com/awalsh128/cache-apt-pkgs-action 2026-06-29 23:15:44 -07:00
awalsh128 6d362b84d4 Put v1 in maintenance mode. 2026-06-29 23:15:16 -07:00
copilot-swe-agent[bot] 553a35bb8e Refactor: extract ARCH_DIRS array to eliminate duplication in consolidate-release 2026-06-29 23:00:54 -07:00
copilot-swe-agent[bot] aecf4c42e4 Fix create-release CI failure: consolidate release artifacts and restrict to workflow_dispatch only 2026-06-29 23:00:54 -07:00
awalsh128 9f817f32fd Merge branch 'master' of https://github.com/awalsh128/cache-apt-pkgs-action 2026-06-29 22:48:17 -07:00
awalsh128 c107d9850d Bump all action dependency versions and pin them 2026-06-29 22:47:54 -07:00
copilot-swe-agent[bot] b3b266d824 fix: ensure create-release job is skipped in dry-run (workflow_call) mode 2026-06-29 22:40:59 -07:00
copilot-swe-agent[bot] 5602509099 fix: address code review feedback in distribute.sh 2026-06-29 22:40:59 -07:00
copilot-swe-agent[bot] a50a475226 fix: create scripts/distribute.sh for build-distribute workflow 2026-06-29 22:40:59 -07:00
awalsh128 869c1d6651 Revert "add shellcheck linting"
This reverts commit e58a49f1de.
2026-06-29 22:29:52 -07:00
Michael Herger 22ad28f4ce Update README with deprecation notice for 'latest'
Added note about deprecation of the 'latest' symbol.
2026-06-27 13:41:09 -07:00
Michael Herger b9c7b1c1a2 Fix version labels and update action version references
Updated version labels and action versions in README. `latest` is deprecated. This change should be reflected in the documentation.
2026-06-27 13:41:09 -07:00
copilot-swe-agent[bot] 5513791f75 fix: handle apt showpkg warnings 2026-06-13 16:56:35 -07:00
copilot-swe-agent[bot] fe5b289324 test: add apt warning regression coverage 2026-06-13 16:56:35 -07:00
Mahyar McDonald e58a49f1de add shellcheck linting
- Updated variable expansions to use double quotes for better safety and to prevent word splitting.
- Replaced `ls` with `find` in cache operations to handle non-alphanumeric filenames more robustly.
- Enhanced array handling in scripts by using `${*:N}` syntax for concatenation.
- Improved readability and consistency in conditional checks by using `[[ ... ]]` instead of `[ ... ]`.
- Added comments for clarity on specific operations and shellcheck directives.
2026-06-13 16:54:54 -07:00
Copilot 599df6ec23
Fix apt-cache package lookup failure in nektos/act environments (#172)
* Initial plan

* Add apt package list update to fix nektos/act compatibility

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

* Remove build artifacts and update .gitignore

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

* Refactor apt list update logic into shared library function

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

* Only update apt lists when running in nektos/act environment

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
Co-authored-by: Andrew Walsh <awalsh128@gmail.com>
2026-06-13 16:49:12 -07:00
Copilot cd5ee21d96
[WIP] Fix test workflows for actions (#184)
* Initial plan

* Fix test workflows to download artifacts and use local action

- Add needs: [build_binaries] to all test jobs that use the action
- Replace remote action references with local (uses: ./)
- Add checkout step where missing
- Add artifact download and distribute directory setup before action usage
- This ensures binaries built by build_binaries job are available when tests run

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
2026-06-13 16:46:15 -07:00
George Joseph c0e0741be6
install_and_cache_pkgs.sh: Fix two issues saving preinst and postinst scripts. (#195)
1.  The logic for listing the files to be cached was using `&&`s between
the listing of the package files, the preinst script and postinst script.
Therefore if there wasn't a preinst script, a postinst script wasn't
checked for.

2. get_install_script_filepath was being passed an empty root file path
so it would never find any files.

Resolves: #194
2026-06-13 16:24:40 -07:00
Copilot 497648d2e1
Apply PR #193 dependency pinning to action.yml (overwrite current action refs) (#201)
* Bump actions/cache off of Node 20

* Bump actions/upload-artifact off of Node 20

---------

Co-authored-by: Sebastian P <241632094+immoseb@users.noreply.github.com>
2026-06-13 16:16:10 -07:00
Paul Keen 681749ae56
fix: upgrade actions/cache v4→v5 and upload-artifact v4→v7 (Node 24) (#198)
Node.js 20 actions are deprecated — GitHub will force Node.js 24
starting June 2, 2026.

- actions/cache/restore v4 → v5
- actions/cache/save v4 → v5
- actions/upload-artifact v4.6.2 → v7

Using version tags for clarity.

See: https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
2026-06-13 16:02:10 -07:00
Dane Wilson acb598e5dd
Pin actions for immutable and secure dependency versions (#175)
Pin dependency actions per security best practices.

https://github.blog/changelog/2025-08-15-github-actions-policy-now-supports-blocking-and-sha-pinning-actions
2025-10-03 23:35:39 -07:00
Copilot 23602f4229
Add support for third-party PPA repositories via add-repository parameter (#173)
* Initial plan

* Add add-repository parameter support for third-party PPAs

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

* Add validation and complete PPA repository support implementation

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

* Remove accidentally committed log file and update .gitignore

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
2025-09-30 01:06:22 -07:00
Copilot 2ae65d5bbf
Fix ls error when no tar files exist in cache restore (#170)
* Initial plan

* Fix ls error when no tar files exist in cache restore

Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: awalsh128 <2087466+awalsh128@users.noreply.github.com>
2025-09-30 01:06:02 -07:00
awalsh128 9f7a885e33 Support symlinks and their targets. 2025-08-29 21:40:34 -07:00
Takahiro Ueda a605dbde2a
Add empty_packages_behavior option to handle empty package list (#154)
Available options: 'error' (default), 'warn' and 'ignore'.
2025-08-16 19:34:34 -07:00
awalsh128 2c09a5e66d Binary for https://github.com/awalsh128/cache-apt-pkgs-action/pull/160 2025-08-10 17:15:27 -07:00
Sébastien Morais 9a146f43d1
fix: skip invalid lines (#160) 2025-08-10 17:11:12 -07:00
Mike Tesch cbdbab28e6
Automatically append the OS architecture to the cache key (#150) 2025-08-10 13:24:23 -07:00
Andrew Walsh 23ccb675d9
Update README.md 2025-07-07 20:37:29 -07:00
Andrew Walsh db548ecc55
Update README.md 2025-07-07 20:35:48 -07:00
Khyber Sen 4c82c3ccdc
Remove GitHub URL shorteners (git.io) as they no longer work. (#164)
Fixes #163.
2025-07-07 20:15:12 -07:00
awalsh128 7ca5f46d06 Fix exec error. 2025-03-16 14:39:03 -07:00
Andrew Walsh 2330cb6dfb
Add support for virtual packages and break out APT logic into common library. (#155)
* Add support for virtual packages and break out APT logic into common library.
* Update binaries from commit 128de25ccb
2025-03-16 13:05:35 -07:00
Andrew Walsh 128de25ccb
Add support for virtual packages and break out APT logic into common library. (#153) 2025-03-16 12:35:38 -07:00
Bradley Scott 13d2226e13
Avoid using xargs when creating package tarballs (#136) 2025-02-04 10:08:04 -08:00
Ülgen Sarıkavak d1a184e480
Update actions/checkout versions in README (#148) 2025-02-03 11:42:51 -08:00
Jacco Broeren dfe9c8af34
fix: remove timestamps from loglines (#146) 2025-01-23 20:00:46 -08:00
Max Schwenk 5902b33ae2
Upgrade to cache v4 (#140) 2025-01-09 11:16:31 -08:00
Andrew Walsh f2fc6d1af4 Explicitly don't fail on error in library calls (required for conditonals) 2024-03-03 14:39:27 -08:00
Oliver Kopp a6c3917cc9
Add arm64 binary (#127)
* Add support for arm64 APT in Go apt-query binary.
2024-03-01 12:59:14 -08:00
Andrew Walsh 2555a377df
Bump force reload to accommodate update on cache action save version. #122 2024-02-13 21:42:01 -08:00
Hadrien G 75ab37ec52
Use matching versions of actions/cache actions (#123)
Needed to finish migration to node20 + probably wiser overall to use matching versions of the caching actions.
2024-02-13 21:38:36 -08:00
Andrew Walsh a9d925863b
Bump global version of cache.
Force cache reload for new version of cache action.
2024-02-13 11:36:57 -08:00
Daniel Possenriede 5c74a020dc
Bump actions/cache/restore to v4 (#120) 2024-02-01 13:13:10 -08:00
Andrew Walsh 6460a33c29
First version of a Golang version for APT package querying. (#118) (#119)
* Pull dev upstream to staging. (#112)

* Use awk to enclose filename in single quotes tar #99

* Add null field separator so filenames don't get broken up.

* Move upload logs up in the action sequence so it captures data before it gets deleted.

* Fix awk (#109)

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>

* Fix awk delimiter.

Pull in fix by @sn-o-w in d0ee83b497 mentioned in issue #99

* Swap out Bash based APT query logic for Golang version. (#117)

* First version of a Golang version of command handling in general. (#118)

---------

Co-authored-by: sn-o-w <cristian.silaghi@mozilla.ro>
2023-12-22 10:28:03 -08:00
35 changed files with 2509 additions and 135 deletions

984
.github/workflows/action-tests.yml vendored Normal file
View file

@ -0,0 +1,984 @@
name: Action Tests
on:
workflow_dispatch:
inputs:
debug:
description: "Run in debug mode."
type: boolean
required: false
default: true
repository_dispatch:
push:
pull_request:
env:
DEBUG: ${{ github.event.inputs.debug || false }}
# Test for overrides in built in shell options (regression issue 98).
SHELLOPTS: errexit:pipefail
jobs:
build_binaries:
uses: ./.github/workflows/build-distribute.yml
# All other jobs should depend on build_binaries (if run) or check_distribute (if not needed)
list_all_versions:
needs: [build_binaries]
runs-on: ubuntu-latest
name: List all package versions (including deps).
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot=1.3-1
version: ${{ github.run_id }}-${{ github.run_attempt }}-list_all_versions
debug: ${{ env.DEBUG }}
- name: Verify
if: |
steps.execute.outputs.cache-hit != 'false' ||
steps.execute.outputs.all-package-version-list != 'fonts-liberation2=1:2.1.5-3,gir1.2-atk-1.0=2.52.0-1build1,gir1.2-freedesktop=1.80.1-1,gir1.2-gdkpixbuf-2.0=2.42.10+dfsg-3ubuntu3.2,gir1.2-gtk-3.0=3.24.41-4ubuntu1.3,gir1.2-harfbuzz-0.0=8.3.0-2build2,gir1.2-pango-1.0=1.52.1+ds-1build1,graphviz=2.42.2-9ubuntu0.1,libann0=1.1.2+doc-9build1,libblas3=3.12.0-3build1.1,libcdt5=2.42.2-9ubuntu0.1,libcgraph6=2.42.2-9ubuntu0.1,libgts-0.7-5t64=0.7.6+darcs121130-5.2build1,libgts-bin=0.7.6+darcs121130-5.2build1,libgvc6=2.42.2-9ubuntu0.1,libgvpr2=2.42.2-9ubuntu0.1,libharfbuzz-gobject0=8.3.0-2build2,liblab-gamut1=2.42.2-9ubuntu0.1,liblapack3=3.12.0-3build1.1,libpangoxft-1.0-0=1.52.1+ds-1build1,libpathplan4=2.42.2-9ubuntu0.1,python3-cairo=1.25.1-2build2,python3-gi-cairo=3.48.2-1,python3-numpy=1:1.26.4+ds-6ubuntu1,xdot=1.3-1'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
echo "package-version-list = ${{ steps.execute.outputs.package-version-list }}"
echo "all-package-version-list = ${{ steps.execute.outputs.all-package-version-list }}"
echo "diff all-package-version-list"
diff <(echo "${{ steps.execute.outputs.all-package-version-list }}" ) <(echo "fonts-liberation2=1:2.1.5-3,gir1.2-atk-1.0=2.52.0-1build1,gir1.2-freedesktop=1.80.1-1,gir1.2-gdkpixbuf-2.0=2.42.10+dfsg-3ubuntu3.2,gir1.2-gtk-3.0=3.24.41-4ubuntu1.3,gir1.2-harfbuzz-0.0=8.3.0-2build2,gir1.2-pango-1.0=1.52.1+ds-1build1,graphviz=2.42.2-9ubuntu0.1,libann0=1.1.2+doc-9build1,libblas3=3.12.0-3build1.1,libcdt5=2.42.2-9ubuntu0.1,libcgraph6=2.42.2-9ubuntu0.1,libgts-0.7-5t64=0.7.6+darcs121130-5.2build1,libgts-bin=0.7.6+darcs121130-5.2build1,libgvc6=2.42.2-9ubuntu0.1,libgvpr2=2.42.2-9ubuntu0.1,libharfbuzz-gobject0=8.3.0-2build2,liblab-gamut1=2.42.2-9ubuntu0.1,liblapack3=3.12.0-3build1.1,libpangoxft-1.0-0=1.52.1+ds-1build1,libpathplan4=2.42.2-9ubuntu0.1,python3-cairo=1.25.1-2build2,python3-gi-cairo=3.48.2-1,python3-numpy=1:1.26.4+ds-6ubuntu1,xdot=1.3-1")
exit 1
shell: bash
list_versions:
needs: [build_binaries]
runs-on: ubuntu-latest
name: List package versions.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice
version: ${{ github.run_id }}-${{ github.run_attempt }}-list_versions
debug: ${{ env.DEBUG }}
- name: Verify
if:
steps.execute.outputs.cache-hit != 'false' || steps.execute.outputs.package-version-list
!= 'rolldice=1.16-1build3,xdot=1.3-1'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
echo "package-version-list = ${{ steps.execute.outputs.package-version-list }}"
echo "diff package-version-list"
diff <(echo "${{ steps.execute.outputs.package-version-list }}" ) <(echo "rolldice=1.16-1build3,xdot=1.3-1")
exit 1
shell: bash
standard_workflow_install:
needs: [build_binaries]
runs-on: ubuntu-latest
name: Standard workflow install package and cache.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice
version: ${{ github.run_id }}-${{ github.run_attempt }}-standard_workflow
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'false'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
standard_workflow_install_with_new_version:
needs: [standard_workflow_install, build_binaries]
runs-on: ubuntu-latest
name: Standard workflow packages with new version.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice
version:
${{ github.run_id }}-${{ github.run_attempt}}-standard_workflow_install_with_new_version
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'false'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
standard_workflow_restore:
needs: [standard_workflow_install, build_binaries]
runs-on: ubuntu-latest
name: Standard workflow restore cached packages.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice
version: ${{ github.run_id }}-${{ github.run_attempt }}-standard_workflow
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'true'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
standard_workflow_restore_with_packages_out_of_order:
needs: [standard_workflow_install, build_binaries]
runs-on: ubuntu-latest
name: Standard workflow restore with packages out of order.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: rolldice xdot
version: ${{ github.run_id }}-${{ github.run_attempt }}-standard_workflow
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'true'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
standard_workflow_add_package:
needs: [standard_workflow_install, build_binaries]
runs-on: ubuntu-latest
name: Standard workflow add another package.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-standard_workflow
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'false'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
standard_workflow_restore_add_package:
needs: [standard_workflow_add_package, build_binaries]
runs-on: ubuntu-latest
name: Standard workflow restore added package.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-standard_workflow
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'true'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
no_packages:
needs: [build_binaries]
runs-on: ubuntu-latest
name: No packages passed.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: ""
continue-on-error: true
- name: Verify
if: steps.execute.outcome == 'failure'
run: exit 0
shell: bash
package_not_found:
needs: [build_binaries]
runs-on: ubuntu-latest
name: Package not found.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: package_that_doesnt_exist
continue-on-error: true
- name: Verify
if: steps.execute.outcome == 'failure'
run: exit 0
shell: bash
version_contains_spaces:
needs: [build_binaries]
runs-on: ubuntu-latest
name: Version contains spaces.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot
version: 123 abc
debug: ${{ env.DEBUG }}
continue-on-error: true
- name: Verify
if: steps.execute.outcome == 'failure'
run: exit 0
shell: bash
regression_36:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Reinstall existing package (regression issue #36)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libgtk-3-dev
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_36
debug: ${{ env.DEBUG }}
regression_37:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Install with reported package dependencies not installed (regression issue #37)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libosmesa6-dev libgl1-mesa-dev python3-tk pandoc git-restore-mtime
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_37
debug: ${{ env.DEBUG }}
debug_disabled:
needs: [build_binaries]
runs-on: ubuntu-latest
name: Debug disabled.
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: xdot
version: ${{ github.run_id }}-${{ github.run_attempt }}-list-all-package-versions
debug: ${{ env.DEBUG }}
regression_72_1:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Cache Java CA certs package v1 (regression issue #72)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: openjdk-11-jre
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_72
debug: ${{ env.DEBUG }}
regression_72_2:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Cache Java CA certs package v2 (regression issue #72)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: default-jre
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_72
debug: ${{ env.DEBUG }}
regression_76:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Cache empty archive (regression issue #76)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- run: |
sudo wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null;
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list;
sudo apt-get -qq update;
sudo apt-get install -y intel-oneapi-runtime-libs intel-oneapi-runtime-opencl;
sudo apt-get install -y opencl-headers ocl-icd-opencl-dev;
sudo apt-get install -y libsundials-dev;
- uses: ./
with:
packages: intel-oneapi-runtime-libs
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_76
debug: ${{ env.DEBUG }}
regression_79:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Tar error with libboost-dev (regression issue #79)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libboost-dev
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_79
debug: ${{ env.DEBUG }}
regression_81:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Tar error with alsa-ucm-conf (regression issue #81)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages:
libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 libcups2 libdrm2 libgbm1
libnspr4 libnss3 libxcomposite1 libxdamage1 libxfixes3 libxkbcommon0 libxrandr2
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_81
debug: ${{ env.DEBUG }}
regression_84_literal_block_install:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Install multiline package listing using literal block style (regression issue #84)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: >
xdot rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_84_literal_block
debug: ${{ env.DEBUG }}
regression_84_literal_block_restore:
needs: [regression_84_literal_block_install, build_binaries]
runs-on: ubuntu-latest
name: "Restore multiline package listing using literal block style (regression issue #84)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_84_literal_block
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'true'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
regression_84_folded_block_install:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Install multiline package listing using literal block style (regression issue #84)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: |
xdot \
rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_84_folded_block
debug: ${{ env.DEBUG }}
regression_84_folded_block_restore:
needs: [regression_84_folded_block_install, build_binaries]
runs-on: ubuntu-latest
name: "Restore multiline package listing using literal block style (regression issue #84)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- name: Execute
id: execute
uses: ./
with:
packages: xdot rolldice distro-info-data
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_84_folded_block
debug: ${{ env.DEBUG }}
- name: Verify
if: steps.execute.outputs.cache-hit != 'true'
run: |
echo "cache-hit = ${{ steps.execute.outputs.cache-hit }}"
exit 1
shell: bash
regression_89:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Upload logs artifact name (regression issue #89)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libgtk-3-dev:amd64
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_89
debug: ${{ env.DEBUG }}
regression_98:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Install error due to SHELLOPTS override (regression issue #98)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: git-restore-mtime libgl1-mesa-dev libosmesa6-dev pandoc
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_98
debug: ${{ env.DEBUG }}
regression_106_install:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Stale apt repo not finding package on restore, install phase (regression issue #106)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libtk8.6
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_106
debug: ${{ env.DEBUG }}
regression_106_restore:
needs: [regression_106_install, build_binaries]
runs-on: ubuntu-latest
name: "Stale apt repo not finding package on restore, restore phase (regression issue #106)."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libtk8.6
version: ${{ github.run_id }}-${{ github.run_attempt }}-regression_106
debug: ${{ env.DEBUG }}
multi_arch_cache_key:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Cache packages with multi-arch cache key."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libfuse2
version: ${{ github.run_id }}-${{ github.run_attempt }}-multi_arch_cache_key
debug: ${{ env.DEBUG }}
virtual_package:
needs: [build_binaries]
runs-on: ubuntu-latest
name: "Cache virtual package."
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Download build artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: cache-apt-pkgs-*
path: distribute-artifacts
- name: Setup distribute directory
shell: bash
run: |
mkdir -p distribute/X64 distribute/X86 distribute/ARM64 distribute/ARM
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*; do
if [ -d "$artifact_dir" ]; then
arch=$(basename "$artifact_dir" | sed 's/cache-apt-pkgs-\([^-]*\)-.*/\1/')
echo "Copying artifacts for architecture: $arch"
cp -r "$artifact_dir"/* "distribute/$arch/" 2>/dev/null || true
fi
done
ls -la distribute/*/ || true
- uses: ./
with:
packages: libvips
version: ${{ github.run_id }}-${{ github.run_attempt }}-virtual_package
debug: ${{ env.DEBUG }}

119
.github/workflows/build-distribute.yml vendored Normal file
View file

@ -0,0 +1,119 @@
name: Build and Release Distribute Artifacts
on:
push:
tags:
- "v2.*.*"
branches:
- dev-v2
workflow_call:
workflow_dispatch:
permissions:
contents: write
id-token: write
env:
VERSION_PREFIX: "commit"
working_directory: ${{ github.workspace }}
jobs:
build-and-release:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
arch: X64
- goos: linux
goarch: arm64
arch: ARM64
- goos: linux
goarch: arm
goarch_variant: "6"
arch: ARM
- goos: linux
goarch: "386"
arch: X86
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version: 1.24
- name: Generate version from commit SHA
id: version
run: ./scripts/distribute.sh generate-version
- name: Create distribute directory
run: ./scripts/distribute.sh create-distribute-directory "${{ matrix.arch }}"
- name: Clone apt-fast repository
run: ./scripts/distribute.sh clone-apt-fast
- name: Build binary for ${{ matrix.goos }}/${{ matrix.goarch }}
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarch_variant }}
CGO_ENABLED: 0
run: |
./scripts/distribute.sh build-binary \
"${{ matrix.goos }}" \
"${{ matrix.goarch }}" \
"${{ matrix.goarch_variant }}" \
"${{ matrix.arch }}"
- name: Generate checksums
run: ./scripts/distribute.sh generate-checksums "${{ matrix.arch }}"
- name: Verify build
run: |
./scripts/distribute.sh verify-build "${{ matrix.arch }}"
- name: Upload artifacts
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: cache-apt-pkgs-${{ matrix.arch }}-${{ steps.version.outputs.commit_sha }}
path: distribute/${{ matrix.arch }}/*
retention-days: 30
create-release:
needs: build-and-release
runs-on: ubuntu-latest
if: success() && github.event_name == 'workflow_dispatch'
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Generate version from commit SHA
id: version
run: |
COMMIT_SHA="${GITHUB_SHA:0:8}"
VERSION="${{ env.VERSION_PREFIX }}-${COMMIT_SHA}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "commit_sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: distribute-artifacts
- name: Reorganize artifacts
run: |
./scripts/distribute.sh reorganize-artifacts
- name: Consolidate release artifacts
run: |
./scripts/distribute.sh consolidate-release
- name: Create or update release
uses: softprops/action-gh-release@2bb465e97f322d3cb2a965294d483e0d26a67aa9 # v3.0.1
with:
tag_name: ${{ steps.version.outputs.version }}
name: "${{ steps.version.outputs.version }}"
generate_release_notes: true
files: |
distribute/release/*
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up old pre-releases
run: |
echo "Cleaning up old commit-based releases..."
# Keep last 10 commit-based releases, delete older ones
gh release list --limit 50 --json tagName,isPrerelease | \
jq -r '.[] | select(.isPrerelease == true and (.tagName | startswith("commit-"))) | .tagName' | \
tail -n +11 | \
xargs -I {} gh release delete {} --yes --cleanup-tag || true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

29
.github/workflows/pull_request.yml vendored Normal file
View file

@ -0,0 +1,29 @@
name: Pull Request
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
jobs:
integrate:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Setup Go
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: "go.mod"
- name: Build and test
run: |
go build -v ./...
go test -v ./...
- name: Lint
uses: golangci/golangci-lint-action@d583c34f0599d37dbac4a198b9c83201be380893 # v9.3.0
with:
version: v1.52.2

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
src/cmd/apt_query/apt_query*
apt_query*
*.log

12
.vscode/launch.json vendored Normal file
View file

@ -0,0 +1,12 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
}
]
}

View file

@ -2,10 +2,13 @@
[![License: Apache2](https://shields.io/badge/license-apache2-blue.svg)](https://github.com/awalsh128/fluentcpp/blob/master/LICENSE)
[![Master Test status](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/master_test.yml/badge.svg)](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/master_test.yml)
[![Staging Test status](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/staging_test.yml/badge.svg)](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/staging_test.yml)
[![Dev Test status](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/dev_test.yml/badge.svg)](https://github.com/awalsh128/cache-apt-pkgs-action-ci/actions/workflows/dev_test.yml)
This action allows caching of Advanced Package Tool (APT) package dependencies to improve workflow execution time instead of installing the packages on every run.
> [!IMPORTANT]
> Version 1 will be in maintenance mode. Due to recently instability in the releases and to create consistent reliability, I am going to lock v1. Version 2 beta will be coming soon to have better testing, and less reliability on Bash script where it has triggered more than one major break.
> [!IMPORTANT]
> Looking for co-maintainers to help review changes, and investigate issues. I haven't had as much time to stay on top of this action as I would like to and want to make sure it is still responsive and reliable for the community. If you are interested, please reach out.
@ -21,26 +24,29 @@ Create a workflow `.yml` file in your repositories `.github/workflows` directory
### Versions
There are three kinds of version labels you can use.
There are two kinds of version labels you can use.
* `@latest` - This will give you the latest release.
* `@v#` - Major only will give you the latest release for that major version only (e.g. `v1`).
* Branch
* `@master` - Most recent manual and automated tested code. Possibly unstable since it is pre-release.
* `@staging` - Most recent automated tested code and can sometimes contain experimental features. Is pulled from dev stable code.
* `@dev` - Very unstable and contains experimental features. Automated testing may not show breaks since CI is also updated based on code in dev.
- `@v#` - Major only will give you the latest release for that major version only (e.g. `v1`).
- Branch
- `@master` - Most recent manual and automated tested code. Possibly unstable since it is pre-release.
- `@staging` - Most recent automated tested code and can sometimes contain experimental features. Is pulled from dev stable code.
- `@dev` - Very unstable and contains experimental features. Automated testing may not show breaks since CI is also updated based on code in dev.
Please note that the `latest` symbol has been deprecated and will no longer be updated. Actions should be pinned to a well known version instead.
### Inputs
* `packages` - Space delimited list of packages to install.
* `version` - Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.
* `execute_install_scripts` - Execute Debian package pre and post install script upon restore. See [Caveats / Non-file Dependencies](#non-file-dependencies) for more information.
- `packages` - Space delimited list of packages to install.
- `version` - Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.
- `execute_install_scripts` - Execute Debian package pre and post install script upon restore. See [Caveats / Non-file Dependencies](#non-file-dependencies) for more information.
- `empty_packages_behavior` - Desired behavior when the given `packages` is empty. `'error'` (default), `'warn'` or `'ignore'`.
- `add-repository` - Space delimited list of repositories to add via `apt-add-repository` before installing packages. Supports PPA (e.g., `ppa:user/repo`) and other repository formats.
### Outputs
* `cache-hit` - A boolean value to indicate a cache was found for the packages requested.
* `package-version-list` - The main requested packages and versions that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. \<package1>=<version1\>,\<package2>=\<version2>,...).
* `all-package-version-list` - All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. \<package1>=<version1\>,\<package2>=\<version2>,...).
- `cache-hit` - A boolean value to indicate a cache was found for the packages requested.
- `package-version-list` - The main requested packages and versions that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. \<package1>=<version1\>,\<package2>=\<version2>,...).
- `all-package-version-list` - All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. \<package1>=<version1\>,\<package2>=\<version2>,...).
### Cache scopes
@ -54,13 +60,12 @@ This was a motivating use case for creating this action.
name: Create Documentation
on: push
jobs:
build_and_deploy_docs:
runs-on: ubuntu-latest
name: Build Doxygen documentation and deploy
steps:
- uses: actions/checkout@v2
- uses: awalsh128/cache-apt-pkgs-action@latest
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
version: 1.0
@ -78,30 +83,61 @@ jobs:
```
```yaml
...
install_doxygen_deps:
---
install_doxygen_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: awalsh128/cache-apt-pkgs-action@latest
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: dia doxygen doxygen-doc doxygen-gui doxygen-latex graphviz mscgen
version: 1.0
```
### Using with Third-party PPAs
This example shows how to install packages from a third-party PPA:
```yaml
install_from_ppa:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: chromium-browser
add-repository: ppa:canonical-chromium-builds/stage
version: 1.0
```
You can also add multiple repositories:
```yaml
install_from_multiple_repos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: package1 package2
add-repository: ppa:user/repo1 ppa:user/repo2
version: 1.0
```
## Caveats
### Non-file Dependencies
This action is based on the principle that most packages can be cached as a fileset. There are situations though where this is not enough.
* Pre and post installation scripts needs to be ran from `/var/lib/dpkg/info/{package name}.[preinst, postinst]`.
* The Debian package database needs to be queried for scripts above (i.e. `dpkg-query`).
- Pre and post installation scripts needs to be ran from `/var/lib/dpkg/info/{package name}.[preinst, postinst]`.
- The Debian package database needs to be queried for scripts above (i.e. `dpkg-query`).
The `execute_install_scripts` argument can be used to attempt to execute the install scripts but they are no guaranteed to resolve the issue.
```yaml
- uses: awalsh128/cache-apt-pkgs-action@latest
- uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: mypackage
version: 1.0
@ -121,4 +157,4 @@ For more context and information see [issue #57](https://github.com/awalsh128/ca
### Cache Limits
A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.
A repository can have up to 5GB of caches. Once the 5GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted. To get more information on how to access and manage your actions's caches, see [GitHub Actions / Using workflows / Cache dependencies](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#viewing-cache-entries).

View file

@ -1,42 +1,56 @@
name: 'Cache APT Packages'
description: 'Install APT based packages and cache them for future runs.'
name: "Cache APT Packages"
description: "Install APT based packages and cache them for future runs."
author: awalsh128
branding:
icon: 'hard-drive'
color: 'green'
icon: "hard-drive"
color: "green"
inputs:
packages:
description: 'Space delimited list of packages to install. Version can be specified optionally using APT command syntax of <name>=<version> (e.g. xdot=1.2-2).'
description: "Space delimited list of packages to install. Version can be specified optionally using APT command syntax of <name>=<version> (e.g. xdot=1.2-2)."
required: true
default: ''
default: ""
version:
description: 'Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed.'
description: "Version of cache to load. Each version will have its own cache. Note, all characters except spaces are allowed."
required: false
default: ''
default: ""
execute_install_scripts:
description: 'Execute Debian package pre and post install script upon restore. See README.md caveats for more information.'
description: "Execute Debian package pre and post install script upon restore. See README.md caveats for more information."
required: false
default: 'false'
default: "false"
empty_packages_behavior:
description: >
Desired behavior when the provided package list is empty.
Available Options:
error: Fail the action with an error message
warn: Output a warning without failing the action
ignore: Proceed silently without warnings or errors
required: false
default: "error"
refresh:
description: 'OBSOLETE: Refresh is not used by the action, use version instead.'
deprecationMessage: 'Refresh is not used by the action, use version instead.'
description: "OBSOLETE: Refresh is not used by the action, use version instead."
deprecationMessage: "Refresh is not used by the action, use version instead."
debug:
description: 'Enable debugging when there are issues with action. Minor performance penalty.'
description: "Enable debugging when there are issues with action. Minor performance penalty."
required: false
default: 'false'
default: "false"
add-repository:
description: "Space delimited list of repositories to add via apt-add-repository before installing packages. Supports PPA (ppa:user/repo) and other repository formats."
required: false
default: ""
outputs:
cache-hit:
description: 'A boolean value to indicate a cache was found for the packages requested.'
description: "A boolean value to indicate a cache was found for the packages requested."
# This compound expression is needed because lhs can be empty.
# Need to output true and false instead of true and nothing.
value: ${{ steps.load-cache.outputs.cache-hit || false }}
package-version-list:
description: 'The main requested packages and versions that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. <package>:<version,<package>:<version>).'
description: "The main requested packages and versions that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. <package>:<version,<package>:<version>)."
value: ${{ steps.post-cache.outputs.package-version-list }}
all-package-version-list:
description: 'All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. <package>:<version,<package>:<version>).'
description: "All the pulled in packages and versions, including dependencies, that are installed. Represented as a comma delimited list with equals delimit on the package version (i.e. <package>:<version,<package>:<version>)."
value: ${{ steps.post-cache.outputs.all-package-version-list }}
runs:
@ -49,22 +63,31 @@ runs:
"$VERSION" \
"$EXEC_INSTALL_SCRIPTS" \
"$DEBUG" \
"$ADD_REPOSITORY" \
"$PACKAGES"
if [ -f ~/cache-apt-pkgs/cache_key.md5 ]; then
echo "CACHE_KEY=$(cat ~/cache-apt-pkgs/cache_key.md5)" >> $GITHUB_ENV
else
echo "CACHE_KEY=" >> $GITHUB_ENV
fi
shell: bash
env:
VERSION: "${{ inputs.version }}"
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
EMPTY_PACKAGES_BEHAVIOR: "${{ inputs.empty_packages_behavior }}"
DEBUG: "${{ inputs.debug }}"
ADD_REPOSITORY: "${{ inputs.add-repository }}"
PACKAGES: "${{ inputs.packages }}"
- id: load-cache
uses: actions/cache/restore@v3
if: ${{ env.CACHE_KEY }}
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/cache-apt-pkgs
key: cache-apt-pkgs_${{ env.CACHE_KEY }}
- id: post-cache
if: ${{ env.CACHE_KEY }}
run: |
${GITHUB_ACTION_PATH}/post_cache_action.sh \
~/cache-apt-pkgs \
@ -72,6 +95,7 @@ runs:
"$CACHE_HIT" \
"$EXEC_INSTALL_SCRIPTS" \
"$DEBUG" \
"$ADD_REPOSITORY" \
"$PACKAGES"
function create_list { local list=$(cat ~/cache-apt-pkgs/manifest_${1}.log | tr '\n' ','); echo ${list:0:-1}; };
echo "package-version-list=$(create_list main)" >> $GITHUB_OUTPUT
@ -81,18 +105,19 @@ runs:
CACHE_HIT: "${{ steps.load-cache.outputs.cache-hit }}"
EXEC_INSTALL_SCRIPTS: "${{ inputs.execute_install_scripts }}"
DEBUG: "${{ inputs.debug }}"
ADD_REPOSITORY: "${{ inputs.add-repository }}"
PACKAGES: "${{ inputs.packages }}"
- id: upload-logs
if: ${{ inputs.debug == 'true' }}
uses: actions/upload-artifact@v3
if: ${{ env.CACHE_KEY && inputs.debug == 'true' }}
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: cache-apt-pkgs-logs_${{ env.CACHE_KEY }}
path: ~/cache-apt-pkgs/*.log
- id: save-cache
if: ${{ ! steps.load-cache.outputs.cache-hit }}
uses: actions/cache/save@v3
if: ${{ env.CACHE_KEY && ! steps.load-cache.outputs.cache-hit }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/cache-apt-pkgs
key: ${{ steps.load-cache.outputs.cache-primary-key }}

BIN
apt_query-arm64 Executable file

Binary file not shown.

BIN
apt_query-x86 Executable file

Binary file not shown.

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module awalsh128.com/cache-apt-pkgs-action
go 1.20

View file

@ -15,26 +15,35 @@ source "${script_dir}/lib.sh"
# Directory that holds the cached packages.
cache_dir="${1}"
# Repositories to add before installing packages.
add_repository="${3}"
# List of the packages to use.
input_packages="${@:3}"
input_packages="${@:4}"
if ! apt-fast --version > /dev/null 2>&1; then
log "Installing apt-fast for optimized installs..."
# Install apt-fast for optimized installs.
/bin/bash -c "$(curl -sL https://git.io/vokNn)"
/bin/bash -c "$(curl -sL https://raw.githubusercontent.com/ilikenwf/apt-fast/master/quick-install.sh)"
log "done"
log_empty_line
fi
log "Updating APT package list..."
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5)" ]]; then
sudo apt-fast update > /dev/null
# Add custom repositories if specified
if [ -n "${add_repository}" ]; then
log "Adding custom repositories..."
for repository in ${add_repository}; do
log "- Adding repository: ${repository}"
sudo apt-add-repository -y "${repository}"
done
log "done"
else
log "skipped (fresh within at least 5 minutes)"
log_empty_line
fi
log "Updating APT package list..."
update_apt_lists_if_stale
log_empty_line
packages="$(get_normalized_package_list "${input_packages}")"
@ -87,14 +96,23 @@ for installed_package in ${installed_packages}; do
read package_name package_ver < <(get_package_name_ver "${installed_package}")
log " * Caching ${package_name} to ${cache_filepath}..."
# Pipe all package files (no folders) and installation control data to Tar.
{ dpkg -L "${package_name}" \
& get_install_script_filepath "" "${package_name}" "preinst" \
& get_install_script_filepath "" "${package_name}" "postinst"; } |
while IFS= read -r f; do test -f "${f}" -o -L "${f}" && get_tar_relpath "${f}"; done |
# Single quotes ensure literals like backslash get captured. Use \0 to avoid field separation.
awk -F"\0" '{print "\x27"$1"\x27"}' |
sudo xargs tar -cf "${cache_filepath}" -C /
# Pipe all package files (no folders), including symlinks, their targets, and installation control data to Tar.
tar -cf "${cache_filepath}" -C / --verbatim-files-from --files-from <(
{ dpkg -L "${package_name}" &&
{ get_install_script_filepath "/" "${package_name}" "preinst" ;
get_install_script_filepath "/" "${package_name}" "postinst" ; } ; } |
while IFS= read -r f; do
if test -f "${f}" -o -L "${f}"; then
get_tar_relpath "${f}"
if [ -L "${f}" ]; then
target="$(readlink -f "${f}")"
if [ -f "${target}" ]; then
get_tar_relpath "${target}"
fi
fi
fi
done
)
log " done (compressed size $(du -h "${cache_filepath}" | cut -f1))."
fi

92
lib.sh
View file

@ -1,5 +1,11 @@
#!/bin/bash
# Don't fail on error. We use the exit status as a conditional.
#
# This is the default behavior but can be overridden by the caller in the
# SHELLOPTS env var.
set +e
###############################################################################
# Execute the Debian install script.
# Arguments:
@ -99,57 +105,17 @@ function get_normalized_package_list {
# Remove commas, and block scalar folded backslashes,
# extraneous spaces at the middle, beginning and end
# then sort.
packages=$(echo "${1}" \
local packages=$(echo "${1}" \
| sed 's/[,\]/ /g; s/\s\+/ /g; s/^\s\+//g; s/\s\+$//g' \
| sort -t' ')
local script_dir="$(dirname -- "$(realpath -- "${0}")")"
# Validate package names and get versions.
log_err "resolving package versions..."
data=$(apt-cache --quiet=0 --no-all-versions show ${packages} 2>&1 | \
grep -E '^(Package|Version|N):')
log_err "resolved"
local ORIG_IFS="${IFS}"
IFS=$'\n'
declare -A missing
local package_versions=''
local package='' separator=''
for key_value in ${data}; do
local key="${key_value%%: *}"
local value="${key_value##*: }"
case $key in
Package)
package=$value
;;
Version)
package_versions="${package_versions}${separator}"${package}=${value}""
separator=' '
;;
N)
# Warning messages.
case $value in
'Unable to locate package '*)
package="${value#'Unable to locate package '}"
# Avoid duplicate messages.
if [ -z "${missing[$package]}" ]; then
package="${value#'Unable to locate package '}"
log_err "Package '${package}' not found."
missing[$package]=1
local architecture=$(dpkg --print-architecture)
if [ "${architecture}" == "arm64" ]; then
${script_dir}/apt_query-arm64 normalized-list ${packages}
else
${script_dir}/apt_query-x86 normalized-list ${packages}
fi
;;
esac
;;
esac
done
IFS="${ORIG_IFS}"
if [ ${#missing[@]} -gt 0 ]; then
echo "aborted"
exit 5
fi
echo "${package_versions}"
}
###############################################################################
@ -169,8 +135,36 @@ function get_tar_relpath {
fi
}
function log { echo "$(date +%T.%3N)" "${@}"; }
function log_err { >&2 echo "$(date +%T.%3N)" "${@}"; }
###############################################################################
# Updates APT package lists if they are stale (modified more than 5 minutes ago).
# This ensures compatibility with environments like nektos/act where package lists
# may be empty or stale. Only runs when ACT environment variable is set (nektos/act)
# to avoid slowing down normal GitHub Actions runs.
# Arguments:
# None
# Returns:
# None
###############################################################################
function update_apt_lists_if_stale {
# Only check for stale package lists when running in nektos/act
# GitHub Actions runners have fresh package lists, so skip this overhead
if [ "${ACT}" = "true" ]; then
if [[ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mmin -5 2>/dev/null)" ]]; then
log "APT package lists are stale, updating..."
if command -v apt-fast > /dev/null 2>&1; then
sudo apt-fast update > /dev/null 2>&1 || sudo apt update > /dev/null 2>&1 || true
else
sudo apt update > /dev/null 2>&1 || true
fi
log "APT package lists updated"
else
log "APT package lists are fresh (within 5 minutes), skipping update"
fi
fi
}
function log { echo "${@}"; }
function log_err { >&2 echo "${@}"; }
function log_empty_line { echo ""; }

View file

@ -25,13 +25,16 @@ execute_install_scripts="${4}"
debug="${5}"
test "${debug}" = "true" && set -x
# Repositories to add before installing packages.
add_repository="${6}"
# List of the packages to use.
packages="${@:6}"
packages="${@:7}"
if test "${cache_hit}" = "true"; then
${script_dir}/restore_pkgs.sh "${cache_dir}" "${cache_restore_root}" "${execute_install_scripts}" "${debug}"
else
${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" ${packages}
${script_dir}/install_and_cache_pkgs.sh "${cache_dir}" "${debug}" "${add_repository}" ${packages}
fi
log_empty_line

View file

@ -24,11 +24,20 @@ execute_install_scripts="${3}"
# Debug mode for diagnosing issues.
debug="${4}"
# Repositories to add before installing packages.
add_repository="${5}"
# List of the packages to use.
input_packages="${@:5}"
input_packages="${@:6}"
# Trim commas, excess spaces, and sort.
log "Normalizing package list..."
# Ensure APT package lists are updated if stale (for nektos/act compatibility)
update_apt_lists_if_stale
packages="$(get_normalized_package_list "${input_packages}")"
log "done"
# Create cache directory so artifacts can be saved.
mkdir -p ${cache_dir}
@ -42,13 +51,39 @@ fi
# Is length of string zero?
if test -z "${packages}"; then
case "$EMPTY_PACKAGES_BEHAVIOR" in
ignore)
exit 0
;;
warn)
echo "::warning::Packages argument is empty."
exit 0
;;
*)
log "aborted"
log "Packages argument cannot be empty." >&2
log "Packages argument is empty." >&2
exit 3
;;
esac
fi
validate_bool "${execute_install_scripts}" execute_install_scripts 4
# Basic validation for repository parameter
if [ -n "${add_repository}" ]; then
log "Validating repository parameter..."
for repository in ${add_repository}; do
# Check if repository format looks valid (basic check)
if [[ "${repository}" =~ [^a-zA-Z0-9:\/.-] ]]; then
log "aborted"
log "Repository '${repository}' contains invalid characters." >&2
log "Supported formats: 'ppa:user/repo', 'deb http://...', 'http://...', 'multiverse', etc." >&2
exit 6
fi
done
log "done"
fi
log "done"
log_empty_line
@ -59,10 +94,27 @@ set -e
log "Creating cache key..."
# Forces an update in cases where an accidental breaking change was introduced
# and a global cache reset is required.
force_update_inc="1"
# and a global cache reset is required, or change in cache action requiring reload.
force_update_inc="3"
# Force a different cache key for different architectures (currently x86_64 and aarch64 are available on GitHub)
cpu_arch="$(arch)"
log "- CPU architecture is '${cpu_arch}'."
value="${packages} @ ${version} ${force_update_inc}"
# Include repositories in cache key to ensure different repos get different caches
if [ -n "${add_repository}" ]; then
value="${value} ${add_repository}"
log "- Repositories '${add_repository}' added to value."
fi
# Don't invalidate existing caches for the standard Ubuntu runners
if [ "${cpu_arch}" != "x86_64" ]; then
value="${value} ${cpu_arch}"
log "- Architecture '${cpu_arch}' added to value."
fi
log "- Value to hash is '${value}'."
key="$(echo "${value}" | md5sum | cut -f1 -d' ')"

View file

@ -40,7 +40,7 @@ log "done"
log_empty_line
# Only search for archived results. Manifest and cache key also live here.
cached_filepaths=$(ls -1 "${cache_dir}"/*.tar | sort)
cached_filepaths=$(ls -1 "${cache_dir}"/*.tar 2>/dev/null | sort)
cached_filecount=$(echo ${cached_filepaths} | wc -w)
log "Restoring ${cached_filecount} packages from cache..."

244
scripts/distribute.sh Executable file
View file

@ -0,0 +1,244 @@
#!/bin/bash
# Script for building and distributing release artifacts.
# Used by the build-distribute.yml workflow.
set -e
COMMAND="${1}"
shift
case "${COMMAND}" in
###############################################################################
# Generate a version string from the current commit SHA.
# Outputs:
# commit_sha: First 8 characters of GITHUB_SHA.
# version: VERSION_PREFIX-commit_sha.
###############################################################################
generate-version)
# GITHUB_SHA, VERSION_PREFIX, and GITHUB_OUTPUT are set by the GitHub Actions runner.
# shellcheck disable=SC2154
COMMIT_SHA="${GITHUB_SHA:0:8}"
# shellcheck disable=SC2154
VERSION="${VERSION_PREFIX}-${COMMIT_SHA}"
# shellcheck disable=SC2154
echo "commit_sha=${COMMIT_SHA}" >> "${GITHUB_OUTPUT}"
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
echo "Generated version: ${VERSION} (commit: ${COMMIT_SHA})"
;;
###############################################################################
# Create the distribution directory for a given architecture and copy action
# files into it.
# Arguments:
# 1: Architecture name (e.g., X64, ARM64, ARM, X86).
###############################################################################
create-distribute-directory)
ARCH="${1}"
DIST_DIR="distribute/${ARCH}"
mkdir -p "${DIST_DIR}"
echo "Created distribution directory: ${DIST_DIR}"
# Copy shell scripts and action definition.
cp ./*.sh "${DIST_DIR}/"
cp action.yml "${DIST_DIR}/"
echo "Copied action files to ${DIST_DIR}"
;;
###############################################################################
# Clone the apt-fast repository for bundling with the distribution.
###############################################################################
clone-apt-fast)
echo "Cloning apt-fast repository..."
git clone --depth=1 https://github.com/ilikenwf/apt-fast.git apt-fast-repo
echo "Cloned apt-fast repository to apt-fast-repo/"
;;
###############################################################################
# Build the apt_query binary for a target architecture.
# Arguments:
# 1: GOOS (e.g., linux).
# 2: GOARCH (e.g., amd64, arm64, arm, 386).
# 3: GOARCH variant (e.g., "6" for armv6; empty string if not applicable).
# 4: Architecture name (e.g., X64, ARM64, ARM, X86).
###############################################################################
build-binary)
GOOS="${1}"
GOARCH="${2}"
GOARCH_VARIANT="${3}"
ARCH="${4}"
ARCH_LOWER="$(echo "${ARCH}" | tr '[:upper:]' '[:lower:]')"
DIST_DIR="distribute/${ARCH}"
BINARY_NAME="apt_query-${ARCH_LOWER}"
OUTPUT="${DIST_DIR}/${BINARY_NAME}"
echo "Building ${BINARY_NAME} for ${GOOS}/${GOARCH} (variant: ${GOARCH_VARIANT:-none})..."
GOOS="${GOOS}" GOARCH="${GOARCH}" GOARM="${GOARCH_VARIANT}" CGO_ENABLED=0 \
go build -o "${OUTPUT}" ./src/cmd/apt_query
chmod +x "${OUTPUT}"
echo "Binary built: ${OUTPUT} ($(du -h "${OUTPUT}" | cut -f1))"
# Copy the apt-fast install script if available.
if [[ -f "apt-fast-repo/apt-fast" ]]; then
cp apt-fast-repo/apt-fast "${DIST_DIR}/"
echo "Bundled apt-fast script in ${DIST_DIR}"
fi
;;
###############################################################################
# Generate SHA256 checksums for all files in the distribution directory.
# Arguments:
# 1: Architecture name (e.g., X64, ARM64, ARM, X86).
###############################################################################
generate-checksums)
ARCH="${1}"
DIST_DIR="distribute/${ARCH}"
CHECKSUM_FILE="${DIST_DIR}/checksums.txt"
echo "Generating checksums for ${DIST_DIR}..."
# Generate checksums for all files except the checksums file itself.
(cd "${DIST_DIR}" && find . -maxdepth 1 -type f ! -name "checksums.txt" \
-exec sha256sum {} + | sed 's|\./||' | sort > checksums.txt)
echo "Checksums written to ${CHECKSUM_FILE}"
cat "${CHECKSUM_FILE}"
;;
###############################################################################
# Verify the build output for a given architecture.
# Arguments:
# 1: Architecture name (e.g., X64, ARM64, ARM, X86).
###############################################################################
verify-build)
ARCH="${1}"
ARCH_LOWER="$(echo "${ARCH}" | tr '[:upper:]' '[:lower:]')"
DIST_DIR="distribute/${ARCH}"
BINARY_NAME="apt_query-${ARCH_LOWER}"
OUTPUT="${DIST_DIR}/${BINARY_NAME}"
if [[ ! -f "${OUTPUT}" ]]; then
echo "Error: Binary not found: ${OUTPUT}" >&2
exit 1
fi
echo "Verifying build: ${OUTPUT}"
file "${OUTPUT}"
# Verify it's an ELF executable.
if ! file "${OUTPUT}" | grep -q "ELF"; then
echo "Error: ${OUTPUT} is not a valid ELF executable" >&2
exit 1
fi
echo "Build verified successfully: ${OUTPUT}"
;;
###############################################################################
# Reorganize downloaded artifacts from distribute-artifacts/ into the
# distribute/<arch>/ layout expected by the release step.
# Artifact directories are named cache-apt-pkgs-<ARCH>-<commit_sha> and
# are mapped to distribute/<arch_lowercase>/.
###############################################################################
reorganize-artifacts)
echo "Reorganizing artifacts..."
# Use nullglob so the loop does not run if no directories match.
shopt -s nullglob
for artifact_dir in distribute-artifacts/cache-apt-pkgs-*/; do
dir_name="$(basename "${artifact_dir}")"
# Extract arch from the format "cache-apt-pkgs-<ARCH>-<8-char-commit-sha>".
# The commit SHA is exactly 8 hex characters at the end.
arch_upper="$(echo "${dir_name}" | sed 's/^cache-apt-pkgs-//; s/-[0-9a-f]\{8\}$//')"
if [[ -z "${arch_upper}" ]]; then
echo "Warning: Could not extract architecture from ${dir_name}, skipping" >&2
continue
fi
arch_lower="$(echo "${arch_upper}" | tr '[:upper:]' '[:lower:]')"
dest_dir="distribute/${arch_lower}"
mkdir -p "${dest_dir}"
cp -r "${artifact_dir}"* "${dest_dir}/"
echo "Reorganized ${artifact_dir} -> ${dest_dir}"
done
shopt -u nullglob
echo "Artifact reorganization complete"
;;
###############################################################################
# Consolidate all per-architecture artifacts into a single flat
# distribute/release/ directory for upload to GitHub Releases.
# Common files (shell scripts, action.yml, apt-fast) are copied once from the
# first available architecture directory. Architecture-specific binaries
# (apt_query-*) are copied from every architecture directory. A combined
# checksums.txt is generated at the end.
###############################################################################
consolidate-release)
RELEASE_DIR="distribute/release"
ARCH_DIRS=(distribute/x64 distribute/arm64 distribute/arm distribute/x86)
mkdir -p "${RELEASE_DIR}"
echo "Consolidating release artifacts into ${RELEASE_DIR}..."
# Find first available arch directory to source common files from.
FIRST_ARCH_DIR=""
for arch_dir in "${ARCH_DIRS[@]}"; do
if [[ -d "${arch_dir}" ]]; then
FIRST_ARCH_DIR="${arch_dir}"
break
fi
done
if [[ -z "${FIRST_ARCH_DIR}" ]]; then
echo "Error: No architecture directories found under distribute/" >&2
exit 1
fi
# Copy common files (everything except arch-specific binaries and checksums)
# from the first arch directory.
shopt -s nullglob
for f in "${FIRST_ARCH_DIR}"/*; do
filename="$(basename "${f}")"
if [[ "${filename}" == apt_query-* ]] || [[ "${filename}" == checksums.txt ]]; then
continue
fi
cp "${f}" "${RELEASE_DIR}/"
echo "Copied common file: ${filename}"
done
shopt -u nullglob
# Copy architecture-specific binaries from every arch directory.
shopt -s nullglob
for arch_dir in "${ARCH_DIRS[@]}"; do
[[ -d "${arch_dir}" ]] || continue
for binary in "${arch_dir}"/apt_query-*; do
cp "${binary}" "${RELEASE_DIR}/"
echo "Copied binary: $(basename "${binary}")"
done
done
shopt -u nullglob
# Generate a combined checksums file for all release assets.
(cd "${RELEASE_DIR}" && find . -maxdepth 1 -type f ! -name "checksums.txt" \
-exec sha256sum {} + | sed 's|\./||' | sort > checksums.txt)
echo "Generated combined checksums:"
cat "${RELEASE_DIR}/checksums.txt"
echo "Consolidation complete. Release directory contents:"
ls -la "${RELEASE_DIR}/"
;;
*)
echo "Error: Unknown command: ${COMMAND}" >&2
echo "Usage: distribute.sh <command> [args...]" >&2
echo "Commands:" >&2
echo " generate-version" >&2
echo " create-distribute-directory <arch>" >&2
echo " clone-apt-fast" >&2
echo " build-binary <goos> <goarch> <goarch_variant> <arch>" >&2
echo " generate-checksums <arch>" >&2
echo " verify-build <arch>" >&2
echo " reorganize-artifacts" >&2
echo " consolidate-release" >&2
exit 1
;;
esac

53
src/cmd/apt_query/main.go Normal file
View file

@ -0,0 +1,53 @@
package main
import (
"flag"
"fmt"
"os"
"awalsh128.com/cache-apt-pkgs-action/src/internal/common"
"awalsh128.com/cache-apt-pkgs-action/src/internal/exec"
"awalsh128.com/cache-apt-pkgs-action/src/internal/logging"
)
func getExecutor(replayFilename string) exec.Executor {
if len(replayFilename) == 0 {
return &exec.BinExecutor{}
}
return exec.NewReplayExecutor(replayFilename)
}
func main() {
debug := flag.Bool("debug", false, "Log diagnostic information to a file alongside the binary.")
replayFilename := flag.String("replayfile", "",
"Replay command output from a specified file rather than executing a binary."+
"The file should be in the same format as the log generated by the debug flag.")
flag.Parse()
unparsedFlags := flag.Args()
logging.Init(os.Args[0]+".log", *debug)
executor := getExecutor(*replayFilename)
if len(unparsedFlags) < 2 {
logging.Fatalf("Expected at least 2 non-flag arguments but found %d.", len(unparsedFlags))
return
}
command := unparsedFlags[0]
pkgNames := unparsedFlags[1:]
switch command {
case "normalized-list":
pkgs, err := common.GetAptPackages(executor, pkgNames)
if err != nil {
logging.Fatalf("Encountered error resolving some or all package names, see combined std[out,err] below.\n%s", err.Error())
}
fmt.Println(pkgs.Serialize())
default:
logging.Fatalf("Command '%s' not recognized.", command)
}
}

View file

@ -0,0 +1,70 @@
package main
import (
"flag"
"testing"
"awalsh128.com/cache-apt-pkgs-action/src/internal/cmdtesting"
)
var createReplayLogs bool = false
func init() {
flag.BoolVar(&createReplayLogs, "createreplaylogs", false, "Execute the test commands, save the command output for future replay and skip the tests themselves.")
}
func TestMain(m *testing.M) {
cmdtesting.TestMain(m)
}
func TestNormalizedList_MultiplePackagesExists_StdoutsAlphaSortedPackageNameVersionPairs(t *testing.T) {
result := cmdtesting.New(t, createReplayLogs).Run("normalized-list", "xdot", "rolldice")
result.ExpectSuccessfulOut("rolldice=1.16-1build1 xdot=1.1-2")
}
func TestNormalizedList_SamePackagesDifferentOrder_StdoutsMatch(t *testing.T) {
expected := "rolldice=1.16-1build1 xdot=1.1-2"
ct := cmdtesting.New(t, createReplayLogs)
result := ct.Run("normalized-list", "rolldice", "xdot")
result.ExpectSuccessfulOut(expected)
result = ct.Run("normalized-list", "xdot", "rolldice")
result.ExpectSuccessfulOut(expected)
}
func TestNormalizedList_MultiVersionWarning_StdoutSingleVersion(t *testing.T) {
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list", "libosmesa6-dev", "libgl1-mesa-dev")
result.ExpectSuccessfulOut("libgl1-mesa-dev=21.2.6-0ubuntu0.1~20.04.2 libosmesa6-dev=21.2.6-0ubuntu0.1~20.04.2")
}
func TestNormalizedList_SinglePackageExists_StdoutsSinglePackageNameVersionPair(t *testing.T) {
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list", "xdot")
result.ExpectSuccessfulOut("xdot=1.1-2")
}
func TestNormalizedList_VersionContainsColon_StdoutsEntireVersion(t *testing.T) {
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list", "default-jre")
result.ExpectSuccessfulOut("default-jre=2:1.11-72")
}
func TestNormalizedList_NonExistentPackageName_StderrsAptCacheErrors(t *testing.T) {
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list", "nonexistentpackagename")
result.ExpectError(
`Error encountered running apt-cache --quiet=0 --no-all-versions show nonexistentpackagename
Exited with status code 100; see combined std[out,err] below:
N: Unable to locate package nonexistentpackagename
N: Unable to locate package nonexistentpackagename
E: No packages found`)
}
func TestNormalizedList_NoPackagesGiven_StderrsArgMismatch(t *testing.T) {
var result = cmdtesting.New(t, createReplayLogs).Run("normalized-list")
result.ExpectError("Expected at least 2 non-flag arguments but found 1.")
}
func TestNormalizedList_VirtualPackagesExists_StdoutsConcretePackage(t *testing.T) {
result := cmdtesting.New(t, createReplayLogs).Run("normalized-list", "libvips")
result.ExpectSuccessfulOut("libvips42=8.9.1-2")
}

View file

@ -0,0 +1,10 @@
2025/03/15 22:29:08 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:09 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show xdot rolldice",
"Stdout": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\nPackage: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\n",
"Stderr": "",
"CombinedOut": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\nPackage: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,10 @@
2025/03/15 22:29:10 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:12 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show libosmesa6-dev libgl1-mesa-dev",
"Stdout": "Package: libosmesa6-dev\nArchitecture: amd64\nVersion: 21.2.6-0ubuntu0.1~20.04.2\nMulti-Arch: same\nPriority: extra\nSection: devel\nSource: mesa\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian X Strike Force \u003cdebian-x@lists.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 88\nProvides: libosmesa-dev\nDepends: libosmesa6 (= 21.2.6-0ubuntu0.1~20.04.2), mesa-common-dev (= 21.2.6-0ubuntu0.1~20.04.2) | libgl-dev\nConflicts: libosmesa-dev\nReplaces: libosmesa-dev\nFilename: pool/main/m/mesa/libosmesa6-dev_21.2.6-0ubuntu0.1~20.04.2_amd64.deb\nSize: 8844\nMD5sum: b6c380d1b916bc6955aaf108a3be468e\nSHA1: 4b772c8127e60a342dabec4ff0939969d99038b4\nSHA256: bf003b66573d611877664e01659046d281b26698f3665345cb784ddded662c6a\nSHA512: 761557925874473e4408504772a0af4d29f6dc1dcbd53e772315dffb6da87d47960edca4de39deda7cae33a8730d87a19b40a7d29739ba7cff5b60ee4900a13a\nHomepage: https://mesa3d.org/\nDescription-en: Mesa Off-screen rendering extension -- development files\n This package provides the required environment for developing programs\n that use the off-screen rendering extension of Mesa.\n .\n For more information on OSmesa see the libosmesa6 package.\nDescription-md5: 9b1d7a0b3e6a2ea021f4443f42dcff4f\n\nPackage: libgl1-mesa-dev\nArchitecture: amd64\nVersion: 21.2.6-0ubuntu0.1~20.04.2\nMulti-Arch: same\nPriority: extra\nSection: libdevel\nSource: mesa\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian X Strike Force \u003cdebian-x@lists.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 70\nDepends: libgl-dev, libglvnd-dev\nFilename: pool/main/m/mesa/libgl1-mesa-dev_21.2.6-0ubuntu0.1~20.04.2_amd64.deb\nSize: 6420\nMD5sum: 759a811dcb12adfcebfc1a6aa52e85b9\nSHA1: 3b9de17b1c67ee40603e1eebaefa978810a2f2d2\nSHA256: 76846d96ae0706a7edcd514d452a1393bb8b8a8ac06518253dd5869441807052\nSHA512: 581e4b3752b4c98399f3519fce2c5ab033cea3cac66bde3c204af769ff0377400087f9c4c6aaebe06c19d05f8715b3346d249a86c3ae80a098ca476e76af01c3\nHomepage: https://mesa3d.org/\nDescription-en: transitional dummy package\n This is a transitional dummy package, it can be safely removed.\nDescription-md5: 635a93bcd1440d16621693fe064c2aa9\n\n",
"Stderr": "N: There are 2 additional records. Please use the '-a' switch to see them.\n",
"CombinedOut": "Package: libosmesa6-dev\nArchitecture: amd64\nVersion: 21.2.6-0ubuntu0.1~20.04.2\nMulti-Arch: same\nPriority: extra\nSection: devel\nSource: mesa\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian X Strike Force \u003cdebian-x@lists.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 88\nProvides: libosmesa-dev\nDepends: libosmesa6 (= 21.2.6-0ubuntu0.1~20.04.2), mesa-common-dev (= 21.2.6-0ubuntu0.1~20.04.2) | libgl-dev\nConflicts: libosmesa-dev\nReplaces: libosmesa-dev\nFilename: pool/main/m/mesa/libosmesa6-dev_21.2.6-0ubuntu0.1~20.04.2_amd64.deb\nSize: 8844\nMD5sum: b6c380d1b916bc6955aaf108a3be468e\nSHA1: 4b772c8127e60a342dabec4ff0939969d99038b4\nSHA256: bf003b66573d611877664e01659046d281b26698f3665345cb784ddded662c6a\nSHA512: 761557925874473e4408504772a0af4d29f6dc1dcbd53e772315dffb6da87d47960edca4de39deda7cae33a8730d87a19b40a7d29739ba7cff5b60ee4900a13a\nHomepage: https://mesa3d.org/\nDescription-en: Mesa Off-screen rendering extension -- development files\n This package provides the required environment for developing programs\n that use the off-screen rendering extension of Mesa.\n .\n For more information on OSmesa see the libosmesa6 package.\nDescription-md5: 9b1d7a0b3e6a2ea021f4443f42dcff4f\n\nPackage: libgl1-mesa-dev\nArchitecture: amd64\nVersion: 21.2.6-0ubuntu0.1~20.04.2\nMulti-Arch: same\nPriority: extra\nSection: libdevel\nSource: mesa\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian X Strike Force \u003cdebian-x@lists.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 70\nDepends: libgl-dev, libglvnd-dev\nFilename: pool/main/m/mesa/libgl1-mesa-dev_21.2.6-0ubuntu0.1~20.04.2_amd64.deb\nSize: 6420\nMD5sum: 759a811dcb12adfcebfc1a6aa52e85b9\nSHA1: 3b9de17b1c67ee40603e1eebaefa978810a2f2d2\nSHA256: 76846d96ae0706a7edcd514d452a1393bb8b8a8ac06518253dd5869441807052\nSHA512: 581e4b3752b4c98399f3519fce2c5ab033cea3cac66bde3c204af769ff0377400087f9c4c6aaebe06c19d05f8715b3346d249a86c3ae80a098ca476e76af01c3\nHomepage: https://mesa3d.org/\nDescription-en: transitional dummy package\n This is a transitional dummy package, it can be safely removed.\nDescription-md5: 635a93bcd1440d16621693fe064c2aa9\n\nN: There are 2 additional records. Please use the '-a' switch to see them.\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,15 @@
2025/03/15 22:29:13 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:14 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show nonexistentpackagename",
"Stdout": "",
"Stderr": "N: Unable to locate package nonexistentpackagename\nN: Unable to locate package nonexistentpackagename\nE: No packages found\n",
"CombinedOut": "N: Unable to locate package nonexistentpackagename\nN: Unable to locate package nonexistentpackagename\nE: No packages found\n",
"ExitCode": 100
}
EXECUTION-OBJ-END
2025/03/15 22:29:14 Error encountered running apt-cache --quiet=0 --no-all-versions show nonexistentpackagename
Exited with status code 100; see combined std[out,err] below:
N: Unable to locate package nonexistentpackagename
N: Unable to locate package nonexistentpackagename
E: No packages found

View file

@ -0,0 +1,2 @@
2025/03/15 22:29:14 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:14 Expected at least 2 non-flag arguments but found 1.

View file

@ -0,0 +1,20 @@
2025/03/15 22:29:09 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:10 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show rolldice xdot",
"Stdout": "Package: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\nPackage: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\n",
"Stderr": "",
"CombinedOut": "Package: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\nPackage: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\n",
"ExitCode": 0
}
EXECUTION-OBJ-END
2025/03/15 22:29:10 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:10 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show xdot rolldice",
"Stdout": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\nPackage: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\n",
"Stderr": "",
"CombinedOut": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\nPackage: rolldice\nArchitecture: amd64\nVersion: 1.16-1build1\nPriority: optional\nSection: universe/games\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Thomas Ross \u003cthomasross@thomasross.io\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 31\nDepends: libc6 (\u003e= 2.7), libreadline8 (\u003e= 6.0)\nFilename: pool/universe/r/rolldice/rolldice_1.16-1build1_amd64.deb\nSize: 9628\nMD5sum: af6390bf2d5d5b4710d308ac06d4913a\nSHA1: 1d87ccac5b20f4e2a217a0e058408f46cfe5caff\nSHA256: 2e076006200057da0be52060e3cc2f4fc7c51212867173e727590bd7603a0337\nHomepage: https://github.com/sstrickl/rolldice\nDescription-en: virtual dice roller\n rolldice is a virtual dice roller that takes a string on the command\n line in the format of some fantasy role playing games like Advanced\n Dungeons \u0026 Dragons [1] and returns the result of the dice rolls.\n .\n [1] Advanced Dungeons \u0026 Dragons is a registered trademark of TSR, Inc.\nDescription-md5: fc24e9e12c794a8f92ab0ca6e1058501\n\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,10 @@
2025/03/15 22:29:12 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:12 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show xdot",
"Stdout": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\n",
"Stderr": "",
"CombinedOut": "Package: xdot\nArchitecture: all\nVersion: 1.1-2\nPriority: optional\nSection: universe/python\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Python Applications Packaging Team \u003cpython-apps-team@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 153\nDepends: gir1.2-gtk-3.0, graphviz, python3-gi, python3-gi-cairo, python3:any\nFilename: pool/universe/x/xdot/xdot_1.1-2_all.deb\nSize: 26708\nMD5sum: aab630b6e1f73a0e3ae85b208b8b6d00\nSHA1: 202155c123c7bd7628023b848e997f342d14359d\nSHA256: 4b7ecb2c4dc948a850024a9b7378d58195230659307bbde4018a1be17645e690\nHomepage: https://github.com/jrfonseca/xdot.py\nDescription-en: interactive viewer for Graphviz dot files\n xdot is an interactive viewer for graphs written in Graphviz's dot language.\n It uses internally the graphviz's xdot output format as an intermediate\n format, and PyGTK and Cairo for rendering. xdot can be used either as a\n standalone application from command line, or as a library embedded in your\n Python 3 application.\n .\n Features:\n * Since it doesn't use bitmaps it is fast and has a small memory footprint.\n * Arbitrary zoom.\n * Keyboard/mouse navigation.\n * Supports events on the nodes with URLs.\n * Animated jumping between nodes.\n * Highlights node/edge under mouse.\nDescription-md5: eb58f25a628b48a744f1b904af3b9282\n\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,10 @@
2025/03/15 22:29:12 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:13 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show default-jre",
"Stdout": "Package: default-jre\nArchitecture: amd64\nVersion: 2:1.11-72\nPriority: optional\nSection: interpreters\nSource: java-common (0.72)\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian Java Maintainers \u003cpkg-java-maintainers@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 6\nProvides: java-runtime, java10-runtime, java11-runtime, java2-runtime, java5-runtime, java6-runtime, java7-runtime, java8-runtime, java9-runtime\nDepends: default-jre-headless (= 2:1.11-72), openjdk-11-jre\nFilename: pool/main/j/java-common/default-jre_1.11-72_amd64.deb\nSize: 1084\nMD5sum: 4f441bb884801f3a07806934e4519652\nSHA1: 9922edaa7bd91921a2beee6c60343ebf551957a9\nSHA256: 063bb2ca3b51309f6625033c336beffb0eb8286aaabcf3bf917eef498de29ea5\nHomepage: https://wiki.debian.org/Java/\nDescription-en: Standard Java or Java compatible Runtime\n This dependency package points to the Java runtime, or Java compatible\n runtime recommended for this architecture, which is\n openjdk-11-jre for amd64.\nDescription-md5: 071b7a2f9baf048d89c849c14bcafb9e\nCnf-Extra-Commands: java,jexec\n\n",
"Stderr": "",
"CombinedOut": "Package: default-jre\nArchitecture: amd64\nVersion: 2:1.11-72\nPriority: optional\nSection: interpreters\nSource: java-common (0.72)\nOrigin: Ubuntu\nMaintainer: Ubuntu Developers \u003cubuntu-devel-discuss@lists.ubuntu.com\u003e\nOriginal-Maintainer: Debian Java Maintainers \u003cpkg-java-maintainers@lists.alioth.debian.org\u003e\nBugs: https://bugs.launchpad.net/ubuntu/+filebug\nInstalled-Size: 6\nProvides: java-runtime, java10-runtime, java11-runtime, java2-runtime, java5-runtime, java6-runtime, java7-runtime, java8-runtime, java9-runtime\nDepends: default-jre-headless (= 2:1.11-72), openjdk-11-jre\nFilename: pool/main/j/java-common/default-jre_1.11-72_amd64.deb\nSize: 1084\nMD5sum: 4f441bb884801f3a07806934e4519652\nSHA1: 9922edaa7bd91921a2beee6c60343ebf551957a9\nSHA256: 063bb2ca3b51309f6625033c336beffb0eb8286aaabcf3bf917eef498de29ea5\nHomepage: https://wiki.debian.org/Java/\nDescription-en: Standard Java or Java compatible Runtime\n This dependency package points to the Java runtime, or Java compatible\n runtime recommended for this architecture, which is\n openjdk-11-jre for amd64.\nDescription-md5: 071b7a2f9baf048d89c849c14bcafb9e\nCnf-Extra-Commands: java,jexec\n\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,19 @@
2025/03/15 22:29:14 Debug log created at /home/awalsh128/cache-apt-pkgs-action/src/cmd/apt_query/apt_query.log
2025/03/15 22:29:14 EXECUTION-OBJ-START
{
"Cmd": "apt-cache --quiet=0 --no-all-versions show libvips",
"Stdout": "",
"Stderr": "N: Can't select candidate version from package libvips as it has no candidate\nN: Can't select versions from package 'libvips' as it is purely virtual\nN: No packages found\n",
"CombinedOut": "N: Can't select candidate version from package libvips as it has no candidate\nN: Can't select versions from package 'libvips' as it is purely virtual\nN: No packages found\n",
"ExitCode": 0
}
EXECUTION-OBJ-END
2025/03/15 22:29:14 EXECUTION-OBJ-START
{
"Cmd": "apt-cache showpkg libvips",
"Stdout": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
"Stderr": "",
"CombinedOut": "Package: libvips\nReverse Provides:\nlibvips42 8.9.1-2 (= )\n",
"ExitCode": 0
}
EXECUTION-OBJ-END

View file

@ -0,0 +1,91 @@
package cmdtesting
import (
"os"
"os/exec"
"strings"
"testing"
"awalsh128.com/cache-apt-pkgs-action/src/internal/common"
)
const binaryName = "apt_query"
type CmdTesting struct {
*testing.T
createReplayLogs bool
replayFilename string
}
func New(t *testing.T, createReplayLogs bool) *CmdTesting {
replayFilename := "testlogs/" + strings.ToLower(t.Name()) + ".log"
if createReplayLogs {
os.Remove(replayFilename)
os.Remove(binaryName + ".log")
}
return &CmdTesting{t, createReplayLogs, replayFilename}
}
type RunResult struct {
Testing *CmdTesting
CombinedOut string
Err error
}
func TestMain(m *testing.M) {
cmd := exec.Command("go", "build")
out, err := cmd.CombinedOutput()
if err != nil {
panic(string(out))
}
os.Exit(m.Run())
}
func (t *CmdTesting) Run(command string, pkgNames ...string) RunResult {
replayfile := "testlogs/" + strings.ToLower(t.Name()) + ".log"
flags := []string{"-debug=true"}
if !t.createReplayLogs {
flags = append(flags, "-replayfile="+replayfile)
}
cmd := exec.Command("./"+binaryName, append(append(flags, command), pkgNames...)...)
combinedOut, err := cmd.CombinedOutput()
if t.createReplayLogs {
err := common.AppendFile(binaryName+".log", t.replayFilename)
if err != nil {
t.T.Fatalf("Error encountered appending log file.\n%s", err.Error())
}
}
return RunResult{Testing: t, CombinedOut: string(combinedOut), Err: err}
}
func (r *RunResult) ExpectSuccessfulOut(expected string) {
if r.Testing.createReplayLogs {
r.Testing.Log("Skipping test while creating replay logs.")
return
}
if r.Err != nil {
r.Testing.Errorf("Error running command: %v\n%s", r.Err, r.CombinedOut)
return
}
fullExpected := expected + "\n" // Output will always have a end of output newline.
if r.CombinedOut != fullExpected {
r.Testing.Errorf("Unexpected combined std[err,out] found.\nExpected:\n'%s'\nActual:\n'%s'", fullExpected, r.CombinedOut)
}
}
func (r *RunResult) ExpectError(expectedCombinedOut string) {
if r.Testing.createReplayLogs {
r.Testing.Log("Skipping test while creating replay logs.")
return
}
fullExpectedCombinedOut := expectedCombinedOut + "\n" // Output will always have a end of output newline.
if r.CombinedOut != fullExpectedCombinedOut {
r.Testing.Errorf("Unexpected combined std[err,out] found.\nExpected:\n'%s'\nActual:\n'%s'", fullExpectedCombinedOut, r.CombinedOut)
}
}

143
src/internal/common/apt.go Normal file
View file

@ -0,0 +1,143 @@
package common
import (
"errors"
"fmt"
"sort"
"strings"
"awalsh128.com/cache-apt-pkgs-action/src/internal/exec"
"awalsh128.com/cache-apt-pkgs-action/src/internal/logging"
)
// An APT package name and version representation.
type AptPackage struct {
Name string
Version string
}
type AptPackages []AptPackage
// Serialize the APT packages into lines of <name>=<version>.
func (ps AptPackages) Serialize() string {
tokens := []string{}
for _, p := range ps {
tokens = append(tokens, p.Name+"="+p.Version)
}
return strings.Join(tokens, " ")
}
func isErrLine(line string) bool {
return strings.HasPrefix(line, "E: ") || strings.HasPrefix(line, "N: ")
}
// Resolves virtual packages names to their concrete one.
func getNonVirtualPackage(executor exec.Executor, name string) (pkg *AptPackage, err error) {
execution := executor.Exec("apt-cache", "showpkg", name)
err = execution.Error()
if err != nil {
logging.Fatal(err)
return pkg, err
}
inReverseProvides := false
for _, line := range strings.Split(execution.CombinedOut, "\n") {
trimmed := strings.TrimSpace(line)
if trimmed == "" {
continue
}
if trimmed == "Reverse Provides:" {
inReverseProvides = true
continue
}
if !inReverseProvides || strings.HasPrefix(trimmed, "W: ") || isErrLine(trimmed) {
continue
}
if strings.HasSuffix(trimmed, ":") {
break
}
splitLine := GetSplitLine(trimmed, " ", 3)
if len(splitLine.Words) < 2 {
continue
}
return &AptPackage{Name: splitLine.Words[0], Version: splitLine.Words[1]}, nil
}
return pkg, fmt.Errorf("unable to parse reverse provides package name and version from apt-cache showpkg output below:\n%s", execution.CombinedOut)
}
func getPackage(executor exec.Executor, paragraph string) (pkg *AptPackage, err error) {
errMsgs := []string{}
for _, splitLine := range GetSplitLines(paragraph, ":", 2) {
if len(splitLine.Words) < 2 {
logging.Debug("Skipping invalid line: %+v\n", splitLine.Line)
continue
}
switch splitLine.Words[0] {
case "Package":
// Initialize since this will provide the first struct value if present.
pkg = &AptPackage{}
pkg.Name = splitLine.Words[1]
case "Version":
pkg.Version = splitLine.Words[1]
case "N":
// e.g. Can't select versions from package 'libvips' as it is purely virtual
if strings.Contains(splitLine.Words[1], "as it is purely virtual") {
return getNonVirtualPackage(executor, GetSplitLine(splitLine.Words[1], "'", 4).Words[2])
}
if strings.HasPrefix(splitLine.Words[1], "Unable to locate package") && !ArrContainsString(errMsgs, splitLine.Line) {
errMsgs = append(errMsgs, splitLine.Line)
}
case "E":
if !ArrContainsString(errMsgs, splitLine.Line) {
errMsgs = append(errMsgs, splitLine.Line)
}
}
}
if len(errMsgs) == 0 {
return pkg, nil
}
return pkg, errors.New(strings.Join(errMsgs, "\n"))
}
// Gets the APT based packages as a sorted by package name list (normalized).
func GetAptPackages(executor exec.Executor, names []string) (AptPackages, error) {
prefixArgs := []string{"--quiet=0", "--no-all-versions", "show"}
execution := executor.Exec("apt-cache", append(prefixArgs, names...)...)
pkgs := []AptPackage{}
err := execution.Error()
if err != nil {
logging.Fatal(err)
return pkgs, err
}
errMsgs := []string{}
for _, paragraph := range strings.Split(execution.CombinedOut, "\n\n") {
trimmed := strings.TrimSpace(paragraph)
if trimmed == "" {
continue
}
pkg, err := getPackage(executor, trimmed)
if err != nil {
errMsgs = append(errMsgs, err.Error())
} else if pkg != nil { // Ignore cases where no package parsed and no errors occurred.
pkgs = append(pkgs, *pkg)
}
}
if len(errMsgs) > 0 {
errMsgs = append(errMsgs, strings.Join(errMsgs, "\n"))
}
sort.Slice(pkgs, func(i, j int) bool {
return pkgs[i].Name < pkgs[j].Name
})
if len(errMsgs) > 0 {
return pkgs, errors.New(strings.Join(errMsgs, "\n"))
}
return pkgs, nil
}

View file

@ -0,0 +1,53 @@
package common
import (
"fmt"
"strings"
"testing"
execpkg "awalsh128.com/cache-apt-pkgs-action/src/internal/exec"
)
type mockExecutor struct {
executions map[string]*execpkg.Execution
}
func (s mockExecutor) Exec(name string, arg ...string) *execpkg.Execution {
cmd := name + " " + strings.Join(arg, " ")
execution, ok := s.executions[cmd]
if !ok {
panic(fmt.Sprintf("unexpected command: %s", cmd))
}
return execution
}
func TestGetNonVirtualPackage_WithWarningsInReverseProvides(t *testing.T) {
executor := mockExecutor{
executions: map[string]*execpkg.Execution{
"apt-cache showpkg libopenblas0-openmp": {
Cmd: "apt-cache showpkg libopenblas0-openmp",
CombinedOut: strings.Join([]string{
"Package: libopenblas0-openmp",
"Reverse Provides:",
"libopenblas0-openmp 0.3.26+ds-1ubuntu0.1 (= )",
"W: Unable to read /etc/apt/apt.conf.d/99github-actions - open (13: Permission denied)",
"",
}, "\n"),
ExitCode: 0,
},
},
}
pkg, err := getNonVirtualPackage(executor, "libopenblas0-openmp")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if pkg == nil {
t.Fatal("expected package but got nil")
}
expected := AptPackage{Name: "libopenblas0-openmp", Version: "0.3.26+ds-1ubuntu0.1"}
if *pkg != expected {
t.Fatalf("unexpected package.\nexpected: %+v\nactual: %+v", expected, *pkg)
}
}

85
src/internal/common/io.go Normal file
View file

@ -0,0 +1,85 @@
package common
import (
"io"
"os"
"path/filepath"
)
func AppendFile(source string, destination string) error {
err := createDirectoryIfNotPresent(filepath.Dir(destination))
if err != nil {
return err
}
in, err := os.Open(source)
if err != nil {
return err
}
defer in.Close()
out, err := os.OpenFile(destination, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
if err != nil {
return err
}
defer out.Close()
data, err := io.ReadAll(in)
if err != nil {
return err
}
_, err = out.Write(data)
if err != nil {
return err
}
return nil
}
func CopyFile(source string, destination string) error {
err := createDirectoryIfNotPresent(filepath.Dir(destination))
if err != nil {
return err
}
in, err := os.Open(source)
if err != nil {
return err
}
defer in.Close()
out, err := os.Create(destination)
if err != nil {
return err
}
defer out.Close()
data, err := io.ReadAll(in)
if err != nil {
return err
}
_, err = out.Write(data)
if err != nil {
return err
}
return nil
}
func MoveFile(source string, destination string) error {
err := createDirectoryIfNotPresent(filepath.Dir(destination))
if err != nil {
return err
}
return os.Rename(source, destination)
}
func createDirectoryIfNotPresent(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
err := os.MkdirAll(path, 0755)
if err != nil {
return err
}
}
return nil
}

View file

@ -0,0 +1,44 @@
package common
import (
"strings"
)
// Checks if an exact string is in an array of strings.
func ArrContainsString(arr []string, element string) bool {
for _, x := range arr {
if x == element {
return true
}
}
return false
}
// A line that has been split into words.
type SplitLine struct {
Line string // The original line.
Words []string // The split words in the line.
}
// Splits a line into words by the delimiter and max number of delimitation.
func GetSplitLine(line string, delimiter string, numWords int) SplitLine {
words := strings.SplitN(line, delimiter, numWords)
trimmedWords := make([]string, len(words))
for i, word := range words {
trimmedWords[i] = strings.TrimSpace(word)
}
return SplitLine{line, trimmedWords}
}
// Splits a paragraph into lines by newline and then splits each line into words specified by the delimiter and max number of delimitation.
func GetSplitLines(paragraph string, delimiter string, numWords int) []SplitLine {
lines := []SplitLine{}
for _, line := range strings.Split(paragraph, "\n") {
trimmed := strings.TrimSpace(line)
if trimmed == "" {
continue
}
lines = append(lines, GetSplitLine(trimmed, delimiter, numWords))
}
return lines
}

View file

@ -0,0 +1,37 @@
package exec
import (
"fmt"
"os/exec"
"strings"
"awalsh128.com/cache-apt-pkgs-action/src/internal/logging"
)
// An executor that proxies command executions from the OS.
//
// NOTE: Extra abstraction layer needed for testing and replay.
type BinExecutor struct{}
func (c *BinExecutor) Exec(name string, arg ...string) *Execution {
cmd := exec.Command(name, arg...)
out, err := cmd.CombinedOutput()
if err != nil {
logging.Fatal(err)
}
execution := &Execution{
Cmd: name + " " + strings.Join(arg, " "),
CombinedOut: string(out),
ExitCode: cmd.ProcessState.ExitCode(),
}
logging.DebugLazy(func() string {
return fmt.Sprintf("EXECUTION-OBJ-START\n%s\nEXECUTION-OBJ-END", execution.Serialize())
})
if err != nil {
logging.Fatal(execution.Error())
}
return execution
}

View file

@ -0,0 +1,49 @@
package exec
import (
"encoding/json"
"fmt"
"awalsh128.com/cache-apt-pkgs-action/src/internal/logging"
)
type Executor interface {
// Executes a command and either returns the output or exits the programs and writes the output (including error) to STDERR.
Exec(name string, arg ...string) *Execution
}
type Execution struct {
Cmd string
CombinedOut string
ExitCode int
}
// Gets the error, if the command ran with a non-zero exit code.
func (e *Execution) Error() error {
if e.ExitCode == 0 {
return nil
}
return fmt.Errorf(
"Error encountered running %s\nExited with status code %d; see combined std[out,err] below:\n%s",
e.Cmd,
e.ExitCode,
e.CombinedOut,
)
}
func DeserializeExecution(payload string) *Execution {
var execution Execution
err := json.Unmarshal([]byte(payload), &execution)
if err != nil {
logging.Fatalf("Error encountered deserializing Execution object.\n%s", err)
}
return &execution
}
func (e *Execution) Serialize() string {
bytes, err := json.MarshalIndent(e, "", " ")
if err != nil {
logging.Fatalf("Error encountered serializing Execution object.\n%s", err)
}
return string(bytes)
}

View file

@ -0,0 +1,74 @@
package exec
import (
"bufio"
"os"
"strings"
"awalsh128.com/cache-apt-pkgs-action/src/internal/logging"
)
// An executor that replays execution results from a recorded result.
type ReplayExecutor struct {
logFilepath string
cmdExecs map[string]*Execution
}
func NewReplayExecutor(logFilepath string) *ReplayExecutor {
file, err := os.Open(logFilepath)
if err != nil {
logging.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
cmdExecs := make(map[string]*Execution)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, "EXECUTION-OBJ-START") {
payload := ""
for scanner.Scan() {
line = scanner.Text()
if strings.Contains(line, "EXECUTION-OBJ-END") {
execution := DeserializeExecution(payload)
cmdExecs[execution.Cmd] = execution
break
} else {
payload += line + "\n"
}
}
}
}
if err := scanner.Err(); err != nil {
logging.Fatal(err)
}
return &ReplayExecutor{logFilepath, cmdExecs}
}
func (e *ReplayExecutor) getCmds() []string {
cmds := []string{}
for cmd := range e.cmdExecs {
cmds = append(cmds, cmd)
}
return cmds
}
func (e *ReplayExecutor) Exec(name string, arg ...string) *Execution {
cmd := name + " " + strings.Join(arg, " ")
value, ok := e.cmdExecs[cmd]
if !ok {
var available string
if len(e.getCmds()) > 0 {
available = "\n" + strings.Join(e.getCmds(), "\n")
} else {
available = " NONE"
}
logging.Fatalf(
"Unable to replay command '%s'.\n"+
"No command found in the debug log; available commands:%s", cmd, available)
}
return value
}

View file

@ -0,0 +1,57 @@
package logging
import (
"fmt"
"log"
"os"
"path/filepath"
)
type Logger struct {
wrapped *log.Logger
Filename string
Debug bool
}
var logger *Logger
var LogFilepath = os.Args[0] + ".log"
func Init(filename string, debug bool) *Logger {
os.Remove(LogFilepath)
file, err := os.OpenFile(LogFilepath, os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Fatal(err)
os.Exit(2)
}
cwd, _ := os.Getwd()
logger = &Logger{
wrapped: log.New(file, "", log.LstdFlags),
Filename: filepath.Join(cwd, file.Name()),
Debug: debug,
}
Debug("Debug log created at %s", logger.Filename)
return logger
}
func DebugLazy(getLine func() string) {
if logger.Debug {
logger.wrapped.Println(getLine())
}
}
func Debug(format string, a ...any) {
if logger.Debug {
logger.wrapped.Printf(format, a...)
}
}
func Fatal(err error) {
fmt.Fprintf(os.Stderr, "%s", err.Error())
logger.wrapped.Fatal(err)
}
func Fatalf(format string, a ...any) {
fmt.Fprintf(os.Stderr, format+"\n", a...)
logger.wrapped.Fatalf(format, a...)
}