Skip to content

ci: use improved cache key set during container build #1

ci: use improved cache key set during container build

ci: use improved cache key set during container build #1

Workflow file for this run

---
name: Test & release
'on':
- pull_request
- push
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
# yamllint disable-line rule:line-length
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
jobs:
should-run:
name: Prep / Should run
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
should-run: ${{ steps.action.outputs.should-run }}
steps:
- id: action
uses:
# yamllint disable-line rule:comments rule:line-length
techneg-it/should-workflow-run@dcbb88600d59ec2842778ef1e2d41f680f876329 # v1.0.0
gtp:
name: Prep / Get platforms
needs:
- should-run
if: fromJSON(needs.should-run.outputs.should-run)
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
test-platforms: ${{ steps.get-test-platforms.outputs.test-platforms }}
steps:
# yamllint disable-line rule:comments
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- id: get-test-platforms
run: |
PLATFORMS=$(
yq '[keys | .[] | select(test("^default-(deb|ubu)"))]' \
-o=json -I=0 .gitlab-ci.yml
)
OUTPUT="test-platforms=$PLATFORMS"
echo "Setting '$OUTPUT'"
echo "$OUTPUT" >> $GITHUB_OUTPUT
pre-commit:
name: Lint / `pre-commit`
needs: should-run
if: fromJSON(needs.should-run.outputs.should-run)
container: techneg/ci-pre-commit:v2.3.1
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# yamllint disable-line rule:comments
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Export `CI_CACHE_ID` from container
run: echo "CI_CACHE_ID=$(cat /.ci_cache_id)" >> $GITHUB_ENV
# yamllint disable-line rule:comments
- uses: actions/[email protected]
with:
path: ~/.cache/pre-commit
key: "${{ env.CI_CACHE_ID }}|\
${{ hashFiles('.pre-commit-config.yaml') }}"
- name: Run `pre-commit`
run: |
git config --global --add safe.directory $(pwd)
pre-commit run --all-files --color always --verbose
test:
name: Test / Kitchen
needs:
- gtp
- pre-commit
- should-run
if: fromJSON(needs.should-run.outputs.should-run)
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
platform: ${{ fromJSON(needs.gtp.outputs.test-platforms) }}
steps:
# yamllint disable-line rule:comments
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
# yamllint disable-line rule:comments
- uses: ruby/[email protected]
with:
bundler-cache: true
ruby-version: 3.1.2
- run: |
bin/kitchen test ${{ matrix.platform }}
test-conversion:
name: Test / Conversion
needs:
- pre-commit
- should-run
if: fromJSON(needs.should-run.outputs.should-run)
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
# yamllint disable-line rule:comments
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Convert the formula
run: |
export CONVERTED=test-the-use_this_template-button
git config user.email "[email protected]"
git config user.name "Test Name"
# Run the conversion script with debug output
DEBUG=true bin/convert-formula.sh "${CONVERTED}"
[ $(git rev-list HEAD --count) -eq 2 ]
# Quick visual check that correct files have been updated
git show --pretty="" --name-status
echo Done!
# yamllint disable-line rule:comments
- uses: ruby/[email protected]
with:
bundler-cache: true
ruby-version: 3.1.2
- name: Test / Kitchen
run: |
bin/kitchen list
bin/kitchen test default-debian-11-master-py3