|
26 | 26 | - "windows-latest" |
27 | 27 | runs-on: ${{ matrix.os }} |
28 | 28 | steps: |
29 | | - - uses: actions/checkout@v4 |
| 29 | + - uses: actions/checkout@v6 |
30 | 30 | - uses: haskell-actions/setup@v2 |
31 | 31 | with: |
32 | 32 | # Should be the current stackage nightly, though this will likely go |
@@ -57,21 +57,94 @@ jobs: |
57 | 57 | if: ${{ failure() && steps.functional.conclusion == 'failure' }} |
58 | 58 | shell: bash |
59 | 59 | run: .github/scripts/print_logs.sh |
60 | | - nix: |
| 60 | + dry-run: |
61 | 61 | strategy: |
62 | 62 | fail-fast: false |
63 | 63 | matrix: |
64 | 64 | os: |
65 | 65 | - "ubuntu-latest" |
66 | 66 | runs-on: ${{ matrix.os }} |
67 | 67 | steps: |
68 | | - - uses: actions/checkout@v4 |
| 68 | + - uses: actions/checkout@v6 |
69 | 69 |
|
70 | 70 | - name: Setup nix |
71 | | - uses: cachix/install-nix-action@v30 |
| 71 | + uses: cachix/install-nix-action@v31 |
72 | 72 | with: |
73 | 73 | github_access_token: ${{ secrets.GITHUB_TOKEN }} |
74 | 74 | nix_path: nixpkgs=channel:nixos-unstable |
75 | 75 |
|
76 | 76 | - name: Dry run |
77 | 77 | run: nix develop .#ci -Lv -c bash -c '.github/scripts/dry_run.sh' |
| 78 | + |
| 79 | + # Upload installed binary so that build-batch does not need to re-install |
| 80 | + # it. |
| 81 | + - name: Upload clc-stackage binary |
| 82 | + uses: actions/upload-artifact@v7 |
| 83 | + with: |
| 84 | + name: clc-stackage-binary |
| 85 | + path: ./bin/clc-stackage |
| 86 | + retention-days: 1 |
| 87 | + |
| 88 | + # Uses jq's 'range(m; n)' operator to create list of indexes from [m, n) |
| 89 | + # for the build-batch job. Slightly nicer than manually listing all of them. |
| 90 | + build-batch-indexes: |
| 91 | + runs-on: "ubuntu-latest" |
| 92 | + outputs: |
| 93 | + indexes: ${{ steps.set-batch-indexes.outputs.indexes }} |
| 94 | + steps: |
| 95 | + - id: set-batch-indexes |
| 96 | + run: echo "indexes=$(jq -cn '[range(1; 19)]')" >> $GITHUB_OUTPUT |
| 97 | + |
| 98 | + # Ideally CI would run a job that actually builds all packages, but this |
| 99 | + # can take a very long time, potentially longer than github's free CI limits |
| 100 | + # (last time checked: 5.5 hrs). |
| 101 | + # |
| 102 | + # What we can do instead, is perform the usual batch process of dividing the |
| 103 | + # package set into groups, then have a different job build each group. |
| 104 | + # This does /not/ run up against github's free CI limits. |
| 105 | + # |
| 106 | + # To do this, we have the script batch_index.sh divide the package set into |
| 107 | + # groups, per --batch. Then, using github's matrix strategy, have each |
| 108 | + # job build only a specific group by passing its index as --batch-index. |
| 109 | + # |
| 110 | + # In other words, each job runs |
| 111 | + # |
| 112 | + # clc-stackage --batch N --batch-index k |
| 113 | + # |
| 114 | + # where k is matrix.index, hence each building a different group. |
| 115 | + # The only other consideration we have, then, is to make sure we have enough |
| 116 | + # indices to cover the whole package set. |
| 117 | + # |
| 118 | + # Currently, we choose --batch to be 200, and the total package set is |
| 119 | + # around 3400, which is filtered to about 3100 packages to build. We thus |
| 120 | + # need at least ceiling(3100 / 200) = 16 indexes to cover this. |
| 121 | + # |
| 122 | + # There is no harm in going overboard e.g. if we have an index that is out of |
| 123 | + # range, that job will simply end with a warning message. We should |
| 124 | + # therefore err on the side of adding too many indices, rather than too few. |
| 125 | + build-batch: |
| 126 | + needs: [build-batch-indexes, dry-run] |
| 127 | + strategy: |
| 128 | + fail-fast: false |
| 129 | + matrix: |
| 130 | + index: ${{ fromJSON(needs.build-batch-indexes.outputs.indexes) }} |
| 131 | + name: Batch group ${{ matrix.index }} |
| 132 | + runs-on: "ubuntu-latest" |
| 133 | + steps: |
| 134 | + - uses: actions/checkout@v6 |
| 135 | + |
| 136 | + - name: Setup nix |
| 137 | + uses: cachix/install-nix-action@v31 |
| 138 | + with: |
| 139 | + github_access_token: ${{ secrets.GITHUB_TOKEN }} |
| 140 | + nix_path: nixpkgs=channel:nixos-unstable |
| 141 | + |
| 142 | + # Download clc-stackage binary from dry-run job. |
| 143 | + - name: Download binary |
| 144 | + uses: actions/download-artifact@v7 |
| 145 | + with: |
| 146 | + name: clc-stackage-binary |
| 147 | + path: ./bin |
| 148 | + |
| 149 | + - name: Build |
| 150 | + run: nix develop .#ci -Lv -c bash -c '.github/scripts/batch_index.sh ${{ matrix.index }}' |
0 commit comments