Selfhosted GHA runner test #625
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| # Trigger the workflow on all pull requests and pushes/merges to main branch | |
| on: | |
| pull_request: | |
| push: | |
| # branches: [main] | |
| # workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| stack: | |
| name: Stack tests | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Stack / GHC | |
| uses: haskell-actions/setup@v2 | |
| with: | |
| ghc-version: '9.8.4' | |
| cabal-version: '3.14.1.1' | |
| enable-stack: true | |
| stack-version: 'latest' | |
| # Ask Stack to use system GHC instead of installing its own copy | |
| - name: Use system GHC | |
| run: | | |
| stack config set system-ghc --global true | |
| - name: Restore cached dependencies | |
| uses: actions/cache/restore@v4 | |
| id: cache | |
| with: | |
| path: ~/.stack | |
| key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} | |
| ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}- | |
| ${{ runner.os }}-ghc-${{ matrix.ghc }}- | |
| - name: Install dependencies | |
| run: stack build --test --only-dependencies | |
| # Cache dependencies already at this point, so that we do not have to | |
| # rebuild them should the subsequent steps fail | |
| - name: Save cached dependencies | |
| uses: actions/cache/save@v4 | |
| # Trying to save over an existing cache gives distracting | |
| # "Warning: Cache save failed." since they are immutable | |
| if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
| with: | |
| path: ~/.stack | |
| key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} | |
| - name: Test with Stack | |
| run: | | |
| .ci/test_stack.sh | |
| fourmolu: | |
| runs-on: self-hosted | |
| steps: | |
| # Note that you must checkout your code before running haskell-actions/run-fourmolu | |
| - uses: actions/checkout@v3 | |
| - uses: haskell-actions/run-fourmolu@v9 | |
| with: | |
| version: "0.14.0.0" | |
| pattern: | | |
| **/*.hs | |
| !clash-protocols-base/src/Protocols/Plugin/Cpp.hs | |
| linting: | |
| name: Source code linting | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Whitespace | |
| run: | | |
| .ci/test_whitespace.sh | |
| nix: | |
| name: Nix/Cabal Tests | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # There's no need to configure Nix, the dockerfile handling the GHA has it done for us! | |
| # If a dependencies are already cached, we can simply re-use them! | |
| - name: Nix Build & Test GHC 9.10.1 | |
| run: | | |
| nix build .#ghc9101.clash-protocols-base | |
| nix build .#ghc9101.clash-protocols | |
| - name: Nix Build & Test GHC 9.8.2 | |
| run: | | |
| nix build .#ghc982.clash-protocols-base | |
| nix build .#ghc982.clash-protocols | |
| - name: Nix Build & Test GHC 9.6.4 | |
| run: | | |
| nix build .#ghc964.clash-protocols-base | |
| nix build .#ghc964.clash-protocols | |
| - name: Push results to cache | |
| env: | |
| ATTIC_TOKEN: ${{ secrets.ATTIC_SECRET }} | |
| run: | | |
| attic login --set-default public http://192.168.102.136:9200/ "$ATTIC_TOKEN" | |
| attic push public $(nix path-info .#ghc9101.clash-protocols-base) | |
| attic push public $(nix path-info .#ghc9101.clash-protocols) | |
| attic push public $(nix path-info .#ghc982.clash-protocols-base) | |
| attic push public $(nix path-info .#ghc982.clash-protocols) | |
| attic push public $(nix path-info .#ghc964.clash-protocols-base) | |
| attic push public $(nix path-info .#ghc964.clash-protocols) | |
| # Mandatory check on GitHub | |
| all: | |
| name: All jobs finished | |
| if: always() | |
| needs: [ | |
| nix, | |
| fourmolu, | |
| linting, | |
| stack, | |
| ] | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Check dependencies for failures | |
| run: | | |
| # Test all dependencies for success/failure | |
| set -x | |
| success="${{ contains(needs.*.result, 'success') }}" | |
| fail="${{ contains(needs.*.result, 'failure') }}" | |
| set +x | |
| # Test whether success/fail variables contain sane values | |
| if [[ "${success}" != "true" && "${success}" != "false" ]]; then exit 1; fi | |
| if [[ "${fail}" != "true" && "${fail}" != "false" ]]; then exit 1; fi | |
| # We want to fail if one or more dependencies fail. For safety, we introduce | |
| # a second check: if no dependencies succeeded something weird is going on. | |
| if [[ "${fail}" == "true" || "${success}" == "false" ]]; then | |
| echo "One or more dependency failed, or no dependency succeeded." | |
| exit 1 | |
| fi | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get -y install python3-yaml | |
| - name: Check that the 'all' job depends on all other jobs | |
| run: | | |
| .github/scripts/all_check.py | |