|
1 | | - |
2 | 1 | name: Verify |
3 | 2 |
|
4 | | -on: [push] |
| 3 | +on: |
| 4 | + push: |
| 5 | + |
| 6 | +permissions: |
| 7 | + contents: read |
| 8 | + packages: write |
| 9 | + |
| 10 | +env: |
| 11 | + GHCR_IMAGE: ghcr.io/kastnerrg/cgra4ml-ibex |
| 12 | + IMAGE_TAG: latest |
5 | 13 |
|
6 | 14 | jobs: |
7 | | - verify-with-verilator: |
8 | | - runs-on: ubuntu-latest |
| 15 | + build-and-push-image: |
| 16 | + runs-on: ubuntu-22.04 |
| 17 | + |
| 18 | + outputs: |
| 19 | + docker_changed: ${{ steps.check-changes.outputs.docker_changed }} |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout code |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - id: check-changes |
| 28 | + name: Detect Docker / env changes |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + set -e |
| 32 | +
|
| 33 | + BEFORE="${{ github.event.before }}" |
| 34 | + SHA="${{ github.sha }}" |
| 35 | +
|
| 36 | + # First push to branch (no "before" commit)? Force rebuild. |
| 37 | + if [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then |
| 38 | + echo "First push on this branch -> rebuild image" |
| 39 | + echo "docker_changed=true" >> "$GITHUB_OUTPUT" |
| 40 | + exit 0 |
| 41 | + fi |
| 42 | +
|
| 43 | + echo "Diffing $BEFORE..$SHA" |
| 44 | + files="$(git diff --name-only "$BEFORE" "$SHA" || true)" |
| 45 | + echo "Changed files:" |
| 46 | + echo "$files" |
| 47 | +
|
| 48 | + if echo "$files" | grep -E '^(Dockerfile|Makefile|pyproject.toml|ibex-soc/python-requirements.txt|ibex-soc/vendor/google_riscv-dv/requirements.txt)$' >/dev/null; then |
| 49 | + echo "Docker / env inputs changed -> rebuild" |
| 50 | + echo "docker_changed=true" >> "$GITHUB_OUTPUT" |
| 51 | + else |
| 52 | + echo "No Dockerfile/Makefile/pyproject/req changes -> reuse existing image" |
| 53 | + echo "docker_changed=false" >> "$GITHUB_OUTPUT" |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Log in to GHCR |
| 57 | + if: steps.check-changes.outputs.docker_changed == 'true' |
| 58 | + uses: docker/login-action@v3 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.actor }} |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Build Docker image via Makefile |
| 65 | + if: steps.check-changes.outputs.docker_changed == 'true' |
| 66 | + shell: bash |
| 67 | + run: | |
| 68 | + # Build using your top-level Makefile, but tag with GHCR_IMAGE:dev |
| 69 | + make IMAGE="${GHCR_IMAGE}:dev" image |
| 70 | + docker tag "${GHCR_IMAGE}:dev" "${GHCR_IMAGE}:${IMAGE_TAG}" |
| 71 | +
|
| 72 | + - name: Push image to GHCR |
| 73 | + if: steps.check-changes.outputs.docker_changed == 'true' |
| 74 | + shell: bash |
| 75 | + run: docker push "${GHCR_IMAGE}:${IMAGE_TAG}" |
| 76 | + |
| 77 | + smoke-test: |
| 78 | + runs-on: ubuntu-22.04 |
| 79 | + needs: build-and-push-image |
| 80 | + |
| 81 | + steps: |
| 82 | + - name: Checkout code |
| 83 | + uses: actions/checkout@v4 |
| 84 | + |
| 85 | + - name: Free disk space on runner |
| 86 | + run: | |
| 87 | + echo "Before cleanup:"; df -h |
| 88 | + sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL || true |
| 89 | + sudo apt-get clean || true |
| 90 | + sudo rm -rf /var/lib/apt/lists/* || true |
| 91 | + docker system prune -af || true |
| 92 | + echo "After cleanup:"; df -h |
| 93 | +
|
| 94 | + - name: Log in to GHCR |
| 95 | + uses: docker/login-action@v3 |
| 96 | + with: |
| 97 | + registry: ghcr.io |
| 98 | + username: ${{ github.actor }} |
| 99 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Pull CI image |
| 102 | + run: docker pull "${GHCR_IMAGE}:${IMAGE_TAG}" |
| 103 | + |
| 104 | + - name: Smoke test (param_test) |
| 105 | + run: | |
| 106 | + docker run --rm \ |
| 107 | + -v "$PWD":/work \ |
| 108 | + -w /work \ |
| 109 | + "${GHCR_IMAGE}:${IMAGE_TAG}" \ |
| 110 | + bash -lc ' |
| 111 | + mkdir -p run/work |
| 112 | + make TEST=param_test smoke_test |
| 113 | + ' |
| 114 | +
|
| 115 | + verify-ibex-soc: |
| 116 | + runs-on: ubuntu-22.04 |
| 117 | + needs: smoke-test |
9 | 118 |
|
10 | 119 | steps: |
11 | | - - uses: actions/checkout@v4 |
12 | | - |
13 | | - - name: Cache modules |
14 | | - id: cache-verify |
15 | | - uses: actions/cache@v3 |
16 | | - env: |
17 | | - cache-name: cache-verify |
18 | | - with: |
19 | | - path: ~/.verify |
20 | | - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
21 | | - restore-keys: | |
22 | | - ${{ runner.os }}-build-${{ env.cache-name }}- |
23 | | - ${{ runner.os }}-build- |
24 | | - ${{ runner.os }}- |
25 | | -
|
26 | | - - name: Set up Python 3.11.5 |
27 | | - uses: actions/setup-python@v4 |
28 | | - with: |
29 | | - python-version: '3.11.5' |
30 | | - |
31 | | - - name: Install Verilator |
32 | | - run: | |
33 | | - sudo apt-get install --only-upgrade python3 |
34 | | - sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache libunwind-dev |
35 | | - sudo apt-get install libgoogle-perftools-dev numactl #perl-doc |
36 | | - sudo apt-get install libfl2 # Ubuntu only (ignore if gives error) |
37 | | - sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error) |
38 | | - # sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error) |
39 | | -
|
40 | | - git clone https://github.com/abarajithan11/verilator-compiled |
41 | | - cd verilator-compiled |
42 | | - tar -C ${HOME} -xzf verilator.tar.gz |
43 | | -
|
44 | | - - name: Install DeepSoCFlow |
45 | | - run: | |
46 | | - python -m pip install --upgrade pip |
47 | | - pip install . |
48 | | -
|
49 | | - - name: Verify Full Design |
50 | | - run: | |
51 | | - export VERILATOR_ROOT=${HOME}/verilator |
52 | | - export PATH=${VERILATOR_ROOT}/bin:${PATH} |
53 | | - export PYMTL_VERILATOR_INCLUDE_DIR=${VERILATOR_ROOT}/share/verilator/include |
54 | | - verilator --version |
55 | | -
|
56 | | - mkdir -p run/work |
57 | | - cd run/work |
58 | | - python -m pytest -s ../param_test.py |
59 | | -
|
60 | | -
|
61 | | - # resnet50: |
62 | | - # runs-on: ubuntu-latest |
63 | | - |
64 | | - # steps: |
65 | | - # - uses: actions/checkout@v2 |
66 | | - |
67 | | - # - name: Cache modules |
68 | | - # id: cache-verify |
69 | | - # uses: actions/cache@v3 |
70 | | - # env: |
71 | | - # cache-name: cache-verify |
72 | | - # with: |
73 | | - # path: ~/.verify |
74 | | - # key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
75 | | - # restore-keys: | |
76 | | - # ${{ runner.os }}-build-${{ env.cache-name }}- |
77 | | - # ${{ runner.os }}-build- |
78 | | - # ${{ runner.os }}- |
79 | | - |
80 | | - # - name: Install Verilator |
81 | | - # run: | |
82 | | - # sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache libunwind-dev |
83 | | - # sudo apt-get install libgoogle-perftools-dev numactl #perl-doc |
84 | | - # sudo apt-get install libfl2 # Ubuntu only (ignore if gives error) |
85 | | - # sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error) |
86 | | - # # sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error) |
87 | | - |
88 | | - # git clone https://github.com/abarajithan11/verilator-compiled |
89 | | - # cd verilator-compiled |
90 | | - # tar -C ${HOME} -xzf verilator.tar.gz |
91 | | - |
92 | | - # - name: Install DeepSoCFlow |
93 | | - # run: | |
94 | | - # pip install . |
95 | | - |
96 | | - # - name: Verify Full Design |
97 | | - # run: | |
98 | | - # export VERILATOR_ROOT=${HOME}/verilator |
99 | | - # export PATH=${VERILATOR_ROOT}/bin:${PATH} |
100 | | - # export PYMTL_VERILATOR_INCLUDE_DIR=${VERILATOR_ROOT}/share/verilator/include |
101 | | - # verilator --version |
102 | | - |
103 | | - # mkdir -p run/work_resnet |
104 | | - # cd run/work_resnet |
105 | | - # python ../resnet_50.py |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Free disk space on runner |
| 124 | + run: | |
| 125 | + echo "Before cleanup:"; df -h |
| 126 | + sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL || true |
| 127 | + sudo apt-get clean || true |
| 128 | + sudo rm -rf /var/lib/apt/lists/* || true |
| 129 | + docker system prune -af || true |
| 130 | + echo "After cleanup:"; df -h |
| 131 | +
|
| 132 | + - name: Log in to GHCR |
| 133 | + uses: docker/login-action@v3 |
| 134 | + with: |
| 135 | + registry: ghcr.io |
| 136 | + username: ${{ github.actor }} |
| 137 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 138 | + |
| 139 | + - name: Pull CI image |
| 140 | + run: docker pull "${GHCR_IMAGE}:${IMAGE_TAG}" |
| 141 | + |
| 142 | + - name: Ibex SoC regression + output check |
| 143 | + run: | |
| 144 | + docker run --rm \ |
| 145 | + -v "$PWD":/work \ |
| 146 | + -w /work \ |
| 147 | + "${GHCR_IMAGE}:${IMAGE_TAG}" \ |
| 148 | + bash -lc ' |
| 149 | + fusesoc library add sa_ip "$(pwd -P)" || true |
| 150 | + mkdir -p run/work |
| 151 | + make TEST=ibex_test smoke_test iclean ibuild irun verify_ibex |
| 152 | + ' |
0 commit comments