Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rules:
line-length:
max: 100
Comment on lines +1 to +3

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this everywhere else as the rustfmt default. Seems ok here

65 changes: 65 additions & 0 deletions apt-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: 'Cache and Install Apt (.deb) Packages'
description: 'A GitHub Action to cache and install Apt (.deb) packages'
inputs:
packages:
description: 'A space-separated list of Apt (.deb) packages to install'
required: true
runs:
using: 'composite'
steps:
- name: Create deb-cache directory if not exists
run: mkdir -p ./deb-cache
shell: bash

- name: Get package versions
id: get-versions
run: |
echo "${{ inputs.packages }}" | tr ' ' '\n' | sed 's/\\//g' | sed '/^$/d' > package-list.txt
cat package-list.txt
while IFS= read -r package; do
version=$(apt-cache policy $package | grep Candidate | awk '{print $2}')
echo "$package=$version" >> package-versions.txt
done < package-list.txt
shell: bash

- name: Set up cache for each package
id: cache-packages
uses: actions/cache@v4
with:
path: ./deb-cache
key: ${{ runner.os }}-deb-${{ hashFiles('package-versions.txt') }}
restore-keys: |
${{ runner.os }}-deb-

- name: Download packages if not cached
env:
DEBIAN_FRONTEND: 'noninteractive'
Comment on lines +35 to +36

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I extracted these out from the script to make yamllint line length restrictions happy. It should work, I think?

run: |
mkdir -p ./deb-cache
cp package-versions.txt ./deb-cache
cp package-list.txt ./deb-cache
cd ./deb-cache
while IFS= read -r package; do
echo "Processing package: $package"
version=$(grep "^$package=" package-versions.txt | cut -d '=' -f 2 || true)
echo "Processing version: $version"
package_file=$(ls $package*.deb 2>/dev/null | head -n 1 || true)

if [ -z "$package_file" ]; then
echo "Cache miss for $package. Downloading version $version..."
rm -f $package-*.deb
apt-get download $package=$version -y -qq --download-only ||
echo "Failed to download $package version $version"
else
echo "Cache hit for $package. Assuming correct version."
fi
done < package-list.txt
shell: bash

- name: Install packages
env:
DEBIAN_FRONTEND: 'noninteractive'
run: |
dpkg -i ./deb-cache/*.deb || sudo dpkg -i ./deb-cache/*.deb || apt-get install -f -y ||
sudo apt-get install -f -y
shell: bash