diff --git a/.github/actions/cache-restore/action.yml b/.github/actions/cache-restore/action.yml new file mode 100644 index 00000000..02a8e1a6 --- /dev/null +++ b/.github/actions/cache-restore/action.yml @@ -0,0 +1,41 @@ +name: 'Restore Build Caches' +description: 'Restore dl/ and .ccache/ caches for Buildroot builds' +inputs: + target: + description: 'Build target for cache key differentiation' + required: true + dl-prefix: + description: 'Prefix for dl/ cache key (e.g., "dl", "dl-boot")' + required: false + default: 'dl' + ccache-prefix: + description: 'Prefix for .ccache/ cache key (e.g., "ccache", "ccache-boot")' + required: false + default: 'ccache' + enabled: + description: 'Set to false to skip cache restoration' + required: false + default: 'true' +runs: + using: 'composite' + steps: + - name: Restore Cache of dl/ + if: ${{ inputs.enabled == 'true' }} + uses: actions/cache@v4 + with: + path: dl/ + key: ${{ inputs.dl-prefix }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} + restore-keys: | + ${{ inputs.dl-prefix }}- + dl- + + - name: Restore Cache of .ccache/ + if: ${{ inputs.enabled == 'true' }} + uses: actions/cache@v4 + with: + path: .ccache/ + key: ${{ inputs.ccache-prefix }}-${{ inputs.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} + restore-keys: | + ${{ inputs.ccache-prefix }}-${{ inputs.target }}- + ${{ inputs.ccache-prefix }}- + ccache- diff --git a/.github/actions/podman-cleanup/action.yml b/.github/actions/podman-cleanup/action.yml new file mode 100644 index 00000000..fc9a6487 --- /dev/null +++ b/.github/actions/podman-cleanup/action.yml @@ -0,0 +1,15 @@ +name: 'Podman Cleanup' +description: 'Clean up stale podman state from previous runs' +runs: + using: 'composite' + steps: + - name: Cleanup podman state + shell: bash + run: | + set -x + podman ps -a || true + podman stop -a || true + podman rm -a -f || true + podman volume prune -f || true + podman system prune -a -f || true + podman system migrate || true diff --git a/.github/workflows/build-boot.yml b/.github/workflows/build-boot.yml index 1a8a849f..f138fd9e 100644 --- a/.github/workflows/build-boot.yml +++ b/.github/workflows/build-boot.yml @@ -64,24 +64,11 @@ jobs: echo "Building ${defconfig}_defconfig, version ${version}-${rev}, artifact ${archive} ..." - - name: Restore Cache of dl/ - uses: actions/cache@v4 + - uses: ./.github/actions/cache-restore with: - path: dl/ - key: dl-boot-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} - restore-keys: | - dl-boot- - dl- - - - name: Restore Cache of .ccache/ - uses: actions/cache@v4 - with: - path: .ccache/ - key: ccache-boot-${{ matrix.defconfig }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} - restore-keys: | - ccache-boot-${{ matrix.defconfig }}- - ccache-boot- - ccache- + target: ${{ matrix.defconfig }} + dl-prefix: dl-boot + ccache-prefix: ccache-boot - name: Configure ${{ matrix.defconfig }}_defconfig run: | diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index a3005b92..1c813947 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -23,21 +23,13 @@ jobs: target: [aarch64, arm, x86_64] fail-fast: false steps: - - name: Cleanup podman state - run: | - set -x - podman ps -a || true - podman stop -a || true - podman rm -a -f || true - podman volume prune -f || true - podman system prune -a -f || true - podman system migrate || true - - uses: actions/checkout@v4 with: clean: true submodules: recursive + - uses: ./.github/actions/podman-cleanup + - name: Set Release Variables id: vars run: | @@ -48,24 +40,10 @@ jobs: echo "dir=infix-$target" >> $GITHUB_OUTPUT echo "tgz=infix-$target.tar.gz" >> $GITHUB_OUTPUT - - name: Restore Cache of dl/ - if: ${{ inputs.use_cache }} - uses: actions/cache@v4 + - uses: ./.github/actions/cache-restore with: - path: dl/ - key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} - restore-keys: | - dl- - - - name: Restore Cache of .ccache/ - if: ${{ inputs.use_cache }} - uses: actions/cache@v4 - with: - path: .ccache/ - key: ccache-${{ matrix.target }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} - restore-keys: | - ccache-${{ matrix.target }}- - ccache- + target: ${{ matrix.target }} + enabled: ${{ inputs.use_cache }} - name: Configure & Build env: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef78e059..538961f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,15 +78,6 @@ jobs: rm -rf ./* || true rm -rf ./.??* || true ls -la ./ - - name: Cleanup podman state - run: | - set -x - podman ps -a || true - podman stop -a || true - podman rm -a -f || true - podman volume prune -f || true - podman system prune -a -f || true - podman system migrate || true - name: Checkout infix repo uses: actions/checkout@v4 @@ -98,6 +89,8 @@ jobs: submodules: recursive token: ${{ secrets.CHECKOUT_TOKEN || github.token }} + - uses: ./.github/actions/podman-cleanup + - name: Run pre-build script if: ${{ inputs.pre_build_script != '' }} run: | @@ -127,22 +120,9 @@ jobs: echo "tgz=${name}-${target}.tar.gz" >> $GITHUB_OUTPUT echo "Building target ${target}_defconfig" - - name: Restore Cache of dl/ - uses: actions/cache@v4 + - uses: ./.github/actions/cache-restore with: - path: dl/ - key: dl-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} - restore-keys: | - dl- - - - name: Restore Cache of .ccache/ - uses: actions/cache@v4 - with: - path: .ccache/ - key: ccache-${{ env.TARGET }}-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} - restore-keys: | - ccache-${{ env.TARGET }}- - ccache- + target: ${{ env.TARGET }} - name: Configure ${{ env.TARGET }} run: | diff --git a/.github/workflows/inventory.yml b/.github/workflows/inventory.yml index f0a6c68a..e99afda8 100644 --- a/.github/workflows/inventory.yml +++ b/.github/workflows/inventory.yml @@ -45,22 +45,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Restore Cache of dl/ - uses: actions/cache@v4 + - uses: ./.github/actions/cache-restore with: - path: dl/ - key: dl-netconf-${{ hashFiles('.git/modules/buildroot/HEAD', 'configs/*', 'package/*/*.hash') }} - restore-keys: | - dl-netconf- - dl- - - name: Restore Cache of .ccache/ - uses: actions/cache@v4 - with: - path: .ccache/ - key: ccache-x86_64-${{ hashFiles('.git/modules/buildroot/HEAD', 'package/*/*.hash') }} - restore-keys: | - ccache-x86_64- - ccache- + target: x86_64 + dl-prefix: dl-netconf - name: Disk inventory (2/2) ... run: | echo "df -h =========================================================================" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4975cdc9..238f37af 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,20 +48,12 @@ jobs: contents: write discussions: write steps: - - name: Cleanup podman state - run: | - set -x - podman ps -a || true - podman stop -a || true - podman rm -a -f || true - podman volume prune -f || true - podman system prune -a -f || true - podman system migrate || true - - uses: actions/checkout@v4 with: submodules: 'true' + - uses: ./.github/actions/podman-cleanup + - name: Set Release Variables id: rel run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f4b8c42..757d7e2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -60,16 +60,6 @@ jobs: name: Regression Test ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.name || inputs.name }} ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.target || inputs.target }} runs-on: [self-hosted, regression] steps: - - name: Cleanup podman state - run: | - set -x - podman ps -a || true - podman stop -a || true - podman rm -a -f || true - podman volume prune -f || true - podman system prune -a -f || true - podman system migrate || true - - name: Checkout infix repo uses: actions/checkout@v4 with: @@ -80,6 +70,8 @@ jobs: submodules: recursive token: ${{ secrets.CHECKOUT_TOKEN || github.token }} + - uses: ./.github/actions/podman-cleanup + - name: Run pre-test script if: ${{ inputs.pre_test_script != '' }} run: | diff --git a/.github/workflows/trigger.yml b/.github/workflows/trigger.yml index 5a7a9f80..4e68ae69 100644 --- a/.github/workflows/trigger.yml +++ b/.github/workflows/trigger.yml @@ -1,4 +1,4 @@ -name: Kernelkit Trigger +name: CI on: pull_request: