diff --git a/.github/workflows/rainix-copy-artifacts.yaml b/.github/workflows/rainix-copy-artifacts.yaml new file mode 100644 index 0000000..bbfd073 --- /dev/null +++ b/.github/workflows/rainix-copy-artifacts.yaml @@ -0,0 +1,54 @@ +name: rainix-copy-artifacts +on: + workflow_call: +jobs: + copy-artifacts: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: nixbuild/nix-quick-install-action@v30 + with: + nix_conf: | + keep-env-derivations = true + keep-outputs = true + # Substitute prebuilt derivations from the shared Cachix cache so the + # toolchain + any prelude build don't refetch crates from crates.io (whose + # download endpoint 403s nix's User-Agent). Pushes new paths when + # CACHIX_AUTH_TOKEN is set; continue-on-error degrades gracefully. + - uses: cachix/cachix-action@v15 + continue-on-error: true + with: + name: rainlanguage + authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} + # No store-watching daemon: it checkpoints the nix DB concurrently + # with cache-nix-action and corrupts it. Push happens in the post step. + useDaemon: false + - name: Restore and save Nix store + uses: nix-community/cache-nix-action@v7 + with: + primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} + restore-prefixes-first-match: nix-${{ runner.os }}- + gc-max-store-size-linux: 8G + - name: Install soldeer dependencies + if: hashFiles('soldeer.lock') != '' + run: nix develop github:rainlanguage/rainix#sol-shell -c forge soldeer install + # No prelude/codegen step on purpose: committing the generated artifacts + # (meta, pointers, abi) is exactly what lets consumers build without a + # prelude. This job rebuilds from the committed sources and asserts the + # committed artifacts still match — it does not regenerate meta inputs. + - name: Regenerate pointer artifacts + if: hashFiles('script/BuildPointers.sol') != '' + run: nix develop github:rainlanguage/rainix#sol-shell -c forge script ./script/BuildPointers.sol + - name: Build Solidity + run: nix develop github:rainlanguage/rainix#sol-shell -c forge build + - name: Copy forge artifacts into committed location + if: hashFiles('script/CopyArtifacts.sol') != '' + run: nix develop github:rainlanguage/rainix#sol-shell -c forge script ./script/CopyArtifacts.sol --ffi + - name: Format (so generated artifacts match committed style) + run: nix develop github:rainlanguage/rainix#sol-shell -c forge fmt + - name: Assert committed artifacts match freshly built + run: | + if ! git diff --exit-code; then + echo "::error::Committed meta/pointer/abi artifacts are stale. Regenerate (.#prelude, BuildPointers.sol, CopyArtifacts.sol, forge fmt) and commit." + exit 1 + fi