|
| 1 | +name: Build and run tests |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + pre_job: |
| 7 | + runs-on: ubuntu-latest |
| 8 | + outputs: |
| 9 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 10 | + steps: |
| 11 | + - id: skip_check |
| 12 | + uses: fkirc/skip-duplicate-actions@v5 |
| 13 | + with: |
| 14 | + paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]' |
| 15 | + # cancel previous builds if a new commit is pushed |
| 16 | + cancel_others: 'true' |
| 17 | + # only run on push *or* pull_request, not both |
| 18 | + concurrent_skipping: 'same_content_newer' |
| 19 | + |
| 20 | + build-yosys: |
| 21 | + name: Reusable build |
| 22 | + runs-on: ${{ matrix.os }} |
| 23 | + needs: pre_job |
| 24 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 25 | + env: |
| 26 | + CC: clang |
| 27 | + strategy: |
| 28 | + matrix: |
| 29 | + os: [ubuntu-latest, macos-latest] |
| 30 | + fail-fast: false |
| 31 | + steps: |
| 32 | + - name: Checkout Yosys |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + submodules: true |
| 36 | + |
| 37 | + - name: Setup environment |
| 38 | + uses: ./.github/actions/setup-build-env |
| 39 | + |
| 40 | + - name: Build |
| 41 | + shell: bash |
| 42 | + run: | |
| 43 | + mkdir build |
| 44 | + cd build |
| 45 | + make -f ../Makefile config-$CC |
| 46 | + make -f ../Makefile -j$procs |
| 47 | +
|
| 48 | + - name: Log yosys-config output |
| 49 | + run: | |
| 50 | + ./yosys-config || true |
| 51 | +
|
| 52 | + - name: Log yosys-config output |
| 53 | + run: | |
| 54 | + ./yosys-config || true |
| 55 | +
|
| 56 | + - name: Compress build |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + cd build |
| 60 | + tar -cvf ../build.tar share/ yosys yosys-* |
| 61 | +
|
| 62 | + - name: Store build artifact |
| 63 | + uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: build-${{ matrix.os }} |
| 66 | + path: build.tar |
| 67 | + retention-days: 1 |
| 68 | + |
| 69 | + test-yosys: |
| 70 | + name: Run tests |
| 71 | + runs-on: ${{ matrix.os }} |
| 72 | + needs: [build-yosys, pre_job] |
| 73 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 74 | + env: |
| 75 | + CC: clang |
| 76 | + strategy: |
| 77 | + matrix: |
| 78 | + os: [ubuntu-latest, macos-latest] |
| 79 | + fail-fast: false |
| 80 | + steps: |
| 81 | + - name: Checkout Yosys |
| 82 | + uses: actions/checkout@v4 |
| 83 | + |
| 84 | + - name: Setup environment |
| 85 | + uses: ./.github/actions/setup-build-env |
| 86 | + |
| 87 | + - name: Get iverilog |
| 88 | + shell: bash |
| 89 | + run: | |
| 90 | + git clone https://github.com/steveicarus/iverilog.git |
| 91 | + cd iverilog |
| 92 | + echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_ENV |
| 93 | +
|
| 94 | + - name: Cache iverilog |
| 95 | + id: cache-iverilog |
| 96 | + uses: actions/cache@v4 |
| 97 | + with: |
| 98 | + path: .local/ |
| 99 | + key: ${{ matrix.os }}-${{ env.IVERILOG_GIT }} |
| 100 | + |
| 101 | + - name: Build iverilog |
| 102 | + if: steps.cache-iverilog.outputs.cache-hit != 'true' |
| 103 | + shell: bash |
| 104 | + run: | |
| 105 | + mkdir -p ${{ github.workspace }}/.local/ |
| 106 | + cd iverilog |
| 107 | + autoconf |
| 108 | + CC=gcc CXX=g++ ./configure --prefix=${{ github.workspace }}/.local |
| 109 | + make -j$procs |
| 110 | + make install |
| 111 | +
|
| 112 | + - name: Download build artifact |
| 113 | + uses: actions/download-artifact@v4 |
| 114 | + with: |
| 115 | + name: build-${{ matrix.os }} |
| 116 | + |
| 117 | + - name: Uncompress build |
| 118 | + shell: bash |
| 119 | + run: |
| 120 | + tar -xvf build.tar |
| 121 | + |
| 122 | + - name: Log yosys-config output |
| 123 | + run: | |
| 124 | + ./yosys-config || true |
| 125 | +
|
| 126 | + - name: Run tests |
| 127 | + shell: bash |
| 128 | + run: | |
| 129 | + make -j$procs test TARGETS= EXTRA_TARGETS= CONFIG=$CC |
| 130 | +
|
| 131 | + - name: Report errors |
| 132 | + if: ${{ failure() }} |
| 133 | + shell: bash |
| 134 | + run: | |
| 135 | + find tests/**/*.err -print -exec cat {} \; |
| 136 | +
|
| 137 | + test-docs: |
| 138 | + name: Run docs tests |
| 139 | + runs-on: ${{ matrix.os }} |
| 140 | + needs: [build-yosys, pre_job] |
| 141 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 142 | + env: |
| 143 | + CC: clang |
| 144 | + strategy: |
| 145 | + matrix: |
| 146 | + os: [ubuntu-latest] |
| 147 | + fail-fast: false |
| 148 | + steps: |
| 149 | + - name: Checkout Yosys |
| 150 | + uses: actions/checkout@v4 |
| 151 | + |
| 152 | + - name: Setup environment |
| 153 | + uses: ./.github/actions/setup-build-env |
| 154 | + |
| 155 | + - name: Download build artifact |
| 156 | + uses: actions/download-artifact@v4 |
| 157 | + with: |
| 158 | + name: build-${{ matrix.os }} |
| 159 | + |
| 160 | + - name: Uncompress build |
| 161 | + shell: bash |
| 162 | + run: |
| 163 | + tar -xvf build.tar |
| 164 | + |
| 165 | + - name: Log yosys-config output |
| 166 | + run: | |
| 167 | + ./yosys-config || true |
| 168 | +
|
| 169 | + - name: Run tests |
| 170 | + shell: bash |
| 171 | + run: | |
| 172 | + make -C docs test -j${{ env.procs }} |
0 commit comments