diff --git a/.github/workflows/contracts-build.yml b/.github/workflows/contracts-build.yml index 957c37494..3ff50126e 100644 --- a/.github/workflows/contracts-build.yml +++ b/.github/workflows/contracts-build.yml @@ -13,7 +13,6 @@ jobs: steps: - name: Check out code uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - name: Install Nix uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31 with: @@ -23,7 +22,6 @@ jobs: run: | pushd contracts nix develop .#contracts -c yarn && yarn build - - name: Run tests run: | pushd contracts @@ -40,6 +38,5 @@ jobs: uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31 with: nix_path: nixpkgs=channel:nixos-unstable - - name: Run build run: nix build -v .#contracts diff --git a/.github/workflows/contracts-publish-compiled-artifacts.yml b/.github/workflows/contracts-publish-compiled-artifacts.yml new file mode 100644 index 000000000..0fdebc6ff --- /dev/null +++ b/.github/workflows/contracts-publish-compiled-artifacts.yml @@ -0,0 +1,115 @@ +name: TON - Publish contract artifacts release + +# This is a custom temporary solution to get the contract build artifacts on other repos and workflows + +permissions: + contents: read + +on: + push: + branches: [ main ] + pull_request: + workflow_dispatch: + inputs: + create_release: + description: "Publish a GitHub release on this manual run?" + type: boolean + default: false + required: false + sha: + description: "Commit SHA to build/release (optional)" + type: string + required: false + +jobs: + changes: + name: Detect changes + runs-on: ubuntu-latest + outputs: + ton_changes: ${{ steps.changes.outputs.ton_changes }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Detect changes + id: changes + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + with: + list-files: "shell" + filters: | + ton_changes: + - 'contracts/**' + - '.github/workflows/contracts-build.yml' + + publish: + name: Build Nix pkg and publish tarball + needs: [ changes ] + if: ${{ needs.changes.outputs.ton_changes == 'true' || github.event_name == 'workflow_dispatch' }} + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Check out code + uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + with: + fetch-depth: 0 + + - name: Get Long and Short SHAs + id: get_sha + run: | + set -euo pipefail + TARGET_SHA="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sha != '' && github.event.inputs.sha || github.sha }}" + FULL_SHA="$(git rev-parse "${TARGET_SHA}")" + { + echo "short_sha=${FULL_SHA:0:12}" + echo "full_sha=${FULL_SHA}" + } >> "$GITHUB_OUTPUT" + + - name: Install Nix + uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31 + with: + nix_path: nixpkgs=channel:nixos-unstable + + - name: Build contracts (Nix) and capture out path + id: nix_build + run: | + set -euo pipefail + OUT_PATH="$(nix build --print-out-paths .#contracts)" + echo "out_path=${OUT_PATH}" >> "$GITHUB_OUTPUT" + echo "Nix out path: ${OUT_PATH}" + + - name: Package from Nix build directory + id: package + run: | + set -euo pipefail + mkdir -p dist + TAR_NAME="ton-contracts-build-${{ steps.get_sha.outputs.short_sha }}.tar.gz" + BUILD_DIR="${{ steps.nix_build.outputs.out_path }}/lib/node_modules/@chainlink/contracts-ton/build" + test -d "${BUILD_DIR}" # hard fail if layout changes + tar -C "${BUILD_DIR}" \ + --exclude="examples.*" \ + -czf "dist/${TAR_NAME}" . + echo "tar_path=dist/${TAR_NAME}" >> "$GITHUB_OUTPUT" + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ton-contracts-build-${{ steps.get_sha.outputs.short_sha }} + path: ${{ steps.package.outputs.tar_path }} + if-no-files-found: error + retention-days: 14 + + - name: Publish Release + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') }} + uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ton-contracts-build-${{ steps.get_sha.outputs.short_sha }} + target_commitish: ${{ steps.get_sha.outputs.full_sha }} + name: TON Contracts Build (${{ steps.get_sha.outputs.short_sha }}) + draft: false + prerelease: false + files: | + ${{ steps.package.outputs.tar_path }} + diff --git a/contracts/tests/ccip/OffRamp.spec.ts b/contracts/tests/ccip/OffRamp.spec.ts index ad11cdfb3..27e24fc73 100644 --- a/contracts/tests/ccip/OffRamp.spec.ts +++ b/contracts/tests/ccip/OffRamp.spec.ts @@ -383,7 +383,7 @@ describe('OffRamp', () => { // Deploy test receiver { - let code = await compile('Receiver') + let code = await compile('examples.receiver') receiver = blockchain.openContract(ExampleReceiver.create(code, offRamp.address)) const result = await receiver.sendDeploy(deployer.getSender(), toNano('10')) expect(result.transactions).toHaveTransaction({ diff --git a/contracts/tests/lib/merkle_proof/MerkleMultiProof.spec.ts b/contracts/tests/lib/merkle_proof/MerkleMultiProof.spec.ts index f58857b96..dda15327e 100644 --- a/contracts/tests/lib/merkle_proof/MerkleMultiProof.spec.ts +++ b/contracts/tests/lib/merkle_proof/MerkleMultiProof.spec.ts @@ -21,7 +21,7 @@ describe('MerkleMultiProofTests', () => { beforeEach(async () => { blockchain = await Blockchain.create() - let code = await compile('MerkleProof') + let code = await compile('examples.MerkleProof') let data: MerkleMultiProofCalculatorStorage = { id: 1, root: 0n, // Initial root, will be updated on deploy diff --git a/contracts/tests/libraries/ocr/MultiOCR3Base.spec.ts b/contracts/tests/libraries/ocr/MultiOCR3Base.spec.ts index fc13223fc..98f2ae1ca 100644 --- a/contracts/tests/libraries/ocr/MultiOCR3Base.spec.ts +++ b/contracts/tests/libraries/ocr/MultiOCR3Base.spec.ts @@ -41,7 +41,7 @@ describe('OCR3Base Tests', () => { const hashedReport = hashReport(report, { configDigest, padding: 0n, sequenceBytes }) beforeAll(async () => { - code = await compile('OCR3Base') + code = await compile('examples.OCR3Base') blockchain = await Blockchain.create() deployer = await blockchain.treasury('deployer') diff --git a/contracts/wrappers/MerkleProof.compile.ts b/contracts/wrappers/examples.MerkleProof.compile.ts similarity index 100% rename from contracts/wrappers/MerkleProof.compile.ts rename to contracts/wrappers/examples.MerkleProof.compile.ts diff --git a/contracts/wrappers/OCR3Base.compile.ts b/contracts/wrappers/examples.OCR3Base.compile.ts similarity index 100% rename from contracts/wrappers/OCR3Base.compile.ts rename to contracts/wrappers/examples.OCR3Base.compile.ts diff --git a/contracts/wrappers/Receiver.compile.ts b/contracts/wrappers/examples.receiver.compile.ts similarity index 100% rename from contracts/wrappers/Receiver.compile.ts rename to contracts/wrappers/examples.receiver.compile.ts