Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize submodule downloads in CI #618

Merged
86 changes: 59 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Get submodules HEAD hash
working-directory: .
run: |
# ownership workaround
git config --global --add safe.directory /__w/coreblocks/coreblocks
# paths in command are relative!
git submodule > .gitmodules-hash

- name: Cache compiled and reference riscv-arch-test
id: cache-riscv-arch-test
Expand All @@ -79,11 +85,17 @@ jobs:
'**/test/external/riscof/coreblocks/**',
'**/test/external/riscof/spike_simple/**',
'**/test/external/riscof/config.ini',
'**/.git/modules/test/external/riscof/riscv-arch-test/HEAD',
'**/docker/riscv-toolchain.Dockerfile'
'**/.gitmodules-hash',
'**/docker/riscv-toolchain.Dockerfile',
'**/.github/workflows/main.yml'
) }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-
lookup-only: true

- if: ${{ steps.cache-riscv-arch-test.outputs.cache-hit != 'true' }}
name: Checkout with submodules
uses: actions/checkout@v3
with:
submodules: recursive

- if: ${{ steps.cache-riscv-arch-test.outputs.cache-hit != 'true' }}
name: Setup PATH
Expand Down Expand Up @@ -112,7 +124,9 @@ jobs:
name: Build tests for Coreblocks
run: |
MAKEFILE_PATH=riscof_work/Makefile.build-DUT-coreblocks ../../../ci/riscof_run_makefile.sh

- if: ${{ steps.cache-riscv-arch-test.outputs.cache-hit != 'true' }}
name: Upload compiled and reference tests artifact
uses: actions/upload-artifact@v3
with:
name: "riscof-tests"
Expand All @@ -130,8 +144,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -146,11 +158,18 @@ jobs:
python3 -m pip install -r requirements-dev.txt

- uses: actions/download-artifact@v3
name: Download full verilog core
with:
name: "verilog-full-core"
path: .

- name: Get submodules HEAD hash
run: |
git config --global --add safe.directory /__w/coreblocks/coreblocks
git submodule > .gitmodules-hash

- uses: actions/cache@v3
name: Download tests from cache
env:
cache-name: cache-riscv-arch-test
with:
Expand All @@ -163,8 +182,9 @@ jobs:
'**/test/external/riscof/coreblocks/**',
'**/test/external/riscof/spike_simple/**',
'**/test/external/riscof/config.ini',
'**/.git/modules/test/external/riscof/riscv-arch-test/HEAD',
'**/docker/riscv-toolchain.Dockerfile'
'**/.gitmodules-hash',
'**/docker/riscv-toolchain.Dockerfile',
'**/.github/workflows/main.yml'
) }}
fail-on-cache-miss: true

Expand All @@ -182,13 +202,14 @@ jobs:
runs-on: ubuntu-latest
container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2024.03.12
timeout-minutes: 10
outputs:
cache_hit: ${{ steps.cache-regression.outputs.cache-hit }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Get submodules HEAD hash
run: |
git config --global --add safe.directory /__w/coreblocks/coreblocks
git submodule > .gitmodules-hash

- name: Cache regression-tests
id: cache-regression
Expand All @@ -197,15 +218,20 @@ jobs:
cache-name: cache-regression-tests
with:
path: test/external/riscv-tests/test-*

key: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(
'**/test/external/riscv-tests/environment/**',
'**/test/external/riscv-tests/environment/custom/**',
'**/test/external/riscv-tests/Makefile',
'**/.git/modules/test/external/riscv-tests/riscv-tests/HEAD',
'**/docker/riscv-toolchain.Dockerfile'
'**/.gitmodules-hash',
'**/docker/riscv-toolchain.Dockerfile',
'**/.github/workflows/main.yml'
) }}
restore-keys: |
${{ env.cache-name }}-${{ runner.os }}-
lookup-only: true

- if: ${{ steps.cache-regression.outputs.cache-hit != 'true' }}
name: Checkout with submodules
uses: actions/checkout@v3
with:
submodules: recursive

- if: ${{ steps.cache-regression.outputs.cache-hit != 'true' }}
run: cd test/external/riscv-tests && make
Expand All @@ -225,8 +251,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -241,21 +265,29 @@ jobs:
python3 -m pip install -r requirements-dev.txt

- uses: actions/download-artifact@v3
name: Download full verilog core
with:
name: "verilog-full-core"
path: .

- name: Get submodules HEAD hash
run: |
git config --global --add safe.directory /__w/coreblocks/coreblocks
git submodule > .gitmodules-hash

- uses: actions/cache@v3
name: Download tests from cache
env:
cache-name: cache-regression-tests
with:
path: test/external/riscv-tests/test-*
key: ${{ env.cache-name }}-${{ runner.os }}-${{ hashFiles(
'**/test/external/riscv-tests/environment/**',
'**/test/external/riscv-tests/Makefile',
'**/.git/modules/test/external/riscv-tests/riscv-tests/HEAD',
'**/docker/riscv-toolchain.Dockerfile'
) }}
'**/test/external/riscv-tests/environment/custom/**',
'**/test/external/riscv-tests/Makefile',
'**/.gitmodules-hash',
'**/docker/riscv-toolchain.Dockerfile',
'**/.github/workflows/main.yml'
) }}
fail-on-cache-miss: true

- name: Run tests
Expand Down
Loading