Repository navigation
77 lines (69 loc) · 2.93 KB
/
Copy pathsample-compile.yml
File metadata and controls
77 lines (69 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Sample compile
on:
pull_request:
paths:
- 'cofhe/**/*.mdx'
- 'cofhe/scripts/compile-samples.py'
- '.github/workflows/sample-compile.yml'
workflow_dispatch:
env:
# The Solidity dependency versions the docs tell readers to install; see
# cofhe/get-started/introduction/compatibility.mdx. cofhe/scripts/check-versions.py
# --docs fails when these disagree with that page.
COFHE_CONTRACTS_VERSION: 1.0.0
CONFIDENTIAL_CONTRACTS_VERSION: 0.4.0
# Pinned like Mint and Vale: forge ships often and its diagnostics change,
# so an unpinned install turns unrelated pull requests red.
FOUNDRY_VERSION: v1.5.1
jobs:
solidity:
name: compile Solidity samples
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# Pages written before this check existed may carry broken samples, so
# a pull request is judged only on the pages it touches. A manual run
# checks the whole site to see the backlog.
- name: Collect pages to check
id: files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
git diff --name-only --diff-filter=d \
"origin/${{ github.base_ref }}...HEAD" -- 'cofhe/*.mdx' 'cofhe/**/*.mdx' > files.txt
else
git ls-files 'cofhe/*.mdx' 'cofhe/**/*.mdx' > files.txt
fi
count=$(wc -l < files.txt | tr -d ' ')
echo "count=$count" >> "$GITHUB_OUTPUT"
echo "Checking $count page(s):"
cat files.txt
- name: Set up Node.js
if: steps.files.outputs.count != '0'
uses: actions/setup-node@v4
with:
node-version: '20'
# --no-save keeps the checkout clean: the repo has no package.json and
# must not gain one. npm also pulls @openzeppelin/contracts, which
# FHE.sol imports, and @openzeppelin/contracts-upgradeable, which the
# confidential token contracts import. One install resolves a single
# cofhe-contracts copy, which fhenix-confidential-contracts pins exactly.
- name: Install Solidity packages
if: steps.files.outputs.count != '0'
run: |
npm install --no-save \
"@fhenixprotocol/cofhe-contracts@${COFHE_CONTRACTS_VERSION}" \
"fhenix-confidential-contracts@${CONFIDENTIAL_CONTRACTS_VERSION}"
- name: Install Foundry
if: steps.files.outputs.count != '0'
uses: foundry-rs/foundry-toolchain@v1
with:
version: ${{ env.FOUNDRY_VERSION }}
# Extracts every ```solidity block from the changed pages and compiles
# each one with forge. The script prints the page, the block number, and
# the compiler error for every failure. TypeScript blocks are not
# checked; this check is Solidity only.
- name: Compile Solidity samples
if: steps.files.outputs.count != '0'
run: xargs -a files.txt python3 cofhe/scripts/compile-samples.py