Skip to content

Commit 374a5ff

Browse files
build: add release and artifact upload to contracts build CI (#146)
* add release and artifact upload to ci, separate testing * fix workflow path on detect changes * try fix for error on contracts test * revert contracts-test change * try testing in the build workflow * delete contracts-test, rename contracts-build-test-release * add flag to manually create the release on workflow dispatch * remove whitespace * rename to previous name to test workflow_dispatch, fix missing title * change name on detect changes * rename back to contracts-build-test.yml * move permissions to the top of the job definition * make artifact and release names match * filter out examples from release * fix compile error on offramp test * separate build and test workflows * build tarball from the nix pkg output * add permissions on test workflow * join workflows back onto only one file * leave original workflow untouched, add custom workflow only for this purpose * fix incorrect triggers for workflow * fix wrong indentation on workflow * fix yml format
1 parent df6a8da commit 374a5ff

File tree

8 files changed

+118
-6
lines changed

8 files changed

+118
-6
lines changed

.github/workflows/contracts-build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ jobs:
1313
steps:
1414
- name: Check out code
1515
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
16-
1716
- name: Install Nix
1817
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
1918
with:
@@ -23,7 +22,6 @@ jobs:
2322
run: |
2423
pushd contracts
2524
nix develop .#contracts -c yarn && yarn build
26-
2725
- name: Run tests
2826
run: |
2927
pushd contracts
@@ -40,6 +38,5 @@ jobs:
4038
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
4139
with:
4240
nix_path: nixpkgs=channel:nixos-unstable
43-
4441
- name: Run build
4542
run: nix build -v .#contracts
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: TON - Publish contract artifacts release
2+
3+
# This is a custom temporary solution to get the contract build artifacts on other repos and workflows
4+
5+
permissions:
6+
contents: read
7+
8+
on:
9+
push:
10+
branches: [ main ]
11+
pull_request:
12+
workflow_dispatch:
13+
inputs:
14+
create_release:
15+
description: "Publish a GitHub release on this manual run?"
16+
type: boolean
17+
default: false
18+
required: false
19+
sha:
20+
description: "Commit SHA to build/release (optional)"
21+
type: string
22+
required: false
23+
24+
jobs:
25+
changes:
26+
name: Detect changes
27+
runs-on: ubuntu-latest
28+
outputs:
29+
ton_changes: ${{ steps.changes.outputs.ton_changes }}
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
persist-credentials: false
35+
- name: Detect changes
36+
id: changes
37+
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
38+
with:
39+
list-files: "shell"
40+
filters: |
41+
ton_changes:
42+
- 'contracts/**'
43+
- '.github/workflows/contracts-build.yml'
44+
45+
publish:
46+
name: Build Nix pkg and publish tarball
47+
needs: [ changes ]
48+
if: ${{ needs.changes.outputs.ton_changes == 'true' || github.event_name == 'workflow_dispatch' }}
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write
52+
steps:
53+
- name: Check out code
54+
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
55+
with:
56+
fetch-depth: 0
57+
58+
- name: Get Long and Short SHAs
59+
id: get_sha
60+
run: |
61+
set -euo pipefail
62+
TARGET_SHA="${{ github.event_name == 'workflow_dispatch' && github.event.inputs.sha != '' && github.event.inputs.sha || github.sha }}"
63+
FULL_SHA="$(git rev-parse "${TARGET_SHA}")"
64+
{
65+
echo "short_sha=${FULL_SHA:0:12}"
66+
echo "full_sha=${FULL_SHA}"
67+
} >> "$GITHUB_OUTPUT"
68+
69+
- name: Install Nix
70+
uses: cachix/install-nix-action@02a151ada4993995686f9ed4f1be7cfbb229e56f # v31
71+
with:
72+
nix_path: nixpkgs=channel:nixos-unstable
73+
74+
- name: Build contracts (Nix) and capture out path
75+
id: nix_build
76+
run: |
77+
set -euo pipefail
78+
OUT_PATH="$(nix build --print-out-paths .#contracts)"
79+
echo "out_path=${OUT_PATH}" >> "$GITHUB_OUTPUT"
80+
echo "Nix out path: ${OUT_PATH}"
81+
82+
- name: Package from Nix build directory
83+
id: package
84+
run: |
85+
set -euo pipefail
86+
mkdir -p dist
87+
TAR_NAME="ton-contracts-build-${{ steps.get_sha.outputs.short_sha }}.tar.gz"
88+
BUILD_DIR="${{ steps.nix_build.outputs.out_path }}/lib/node_modules/@chainlink/contracts-ton/build"
89+
test -d "${BUILD_DIR}" # hard fail if layout changes
90+
tar -C "${BUILD_DIR}" \
91+
--exclude="examples.*" \
92+
-czf "dist/${TAR_NAME}" .
93+
echo "tar_path=dist/${TAR_NAME}" >> "$GITHUB_OUTPUT"
94+
95+
- name: Upload artifact
96+
uses: actions/upload-artifact@v4
97+
with:
98+
name: ton-contracts-build-${{ steps.get_sha.outputs.short_sha }}
99+
path: ${{ steps.package.outputs.tar_path }}
100+
if-no-files-found: error
101+
retention-days: 14
102+
103+
- name: Publish Release
104+
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && github.event.inputs.create_release == 'true') }}
105+
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1
106+
with:
107+
token: ${{ secrets.GITHUB_TOKEN }}
108+
tag_name: ton-contracts-build-${{ steps.get_sha.outputs.short_sha }}
109+
target_commitish: ${{ steps.get_sha.outputs.full_sha }}
110+
name: TON Contracts Build (${{ steps.get_sha.outputs.short_sha }})
111+
draft: false
112+
prerelease: false
113+
files: |
114+
${{ steps.package.outputs.tar_path }}
115+

contracts/tests/ccip/OffRamp.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ describe('OffRamp', () => {
383383

384384
// Deploy test receiver
385385
{
386-
let code = await compile('Receiver')
386+
let code = await compile('examples.receiver')
387387
receiver = blockchain.openContract(ExampleReceiver.create(code, offRamp.address))
388388
const result = await receiver.sendDeploy(deployer.getSender(), toNano('10'))
389389
expect(result.transactions).toHaveTransaction({

contracts/tests/lib/merkle_proof/MerkleMultiProof.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('MerkleMultiProofTests', () => {
2121
beforeEach(async () => {
2222
blockchain = await Blockchain.create()
2323

24-
let code = await compile('MerkleProof')
24+
let code = await compile('examples.MerkleProof')
2525
let data: MerkleMultiProofCalculatorStorage = {
2626
id: 1,
2727
root: 0n, // Initial root, will be updated on deploy

contracts/tests/libraries/ocr/MultiOCR3Base.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('OCR3Base Tests', () => {
4141
const hashedReport = hashReport(report, { configDigest, padding: 0n, sequenceBytes })
4242

4343
beforeAll(async () => {
44-
code = await compile('OCR3Base')
44+
code = await compile('examples.OCR3Base')
4545
blockchain = await Blockchain.create()
4646

4747
deployer = await blockchain.treasury('deployer')
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)