Skip to content

Commit be2e60b

Browse files
authored
Merge pull request #1 from lsd-ucsc/adding-github-actions
- Added GitHub Actions for - Unit testing - Version release
2 parents 47cc7df + 61d6146 commit be2e60b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1097
-413
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
name: Create release
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- "v*.*.*"
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
create_release:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ ubuntu-22.04 ]
17+
18+
python-version: [ 3.11 ]
19+
node-version: [ 18.16.0 ]
20+
21+
ganache-version: [ 7.8.0 ]
22+
23+
solc-version: [ v0.8.20 ]
24+
25+
env:
26+
SOLC_BIN: ${{ github.workspace }}/build/solc-static-linux
27+
SOLC_FLAGS: >-
28+
--optimize --optimize-runs 200
29+
--revert-strings strip
30+
--via-ir
31+
--overwrite
32+
--base-path ${{ github.workspace }}
33+
--output-dir ${{ github.workspace }}/build/
34+
SOLC_VER_CMD: >-
35+
${{ github.workspace }}/build/solc-static-linux
36+
--version | tail -n 1 | sed -e "s/^Version: //g"
37+
RELE_NOTE: ${{ github.workspace }}/build/release_note.md
38+
39+
name: A job to create a release
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
with:
44+
submodules: recursive
45+
46+
- name: Installing Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v4
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
51+
- name: Installing Python packages
52+
run: |
53+
python3 -m pip install --requirement ${{ github.workspace }}/utils/gas_cost_eval_requirements.txt
54+
55+
- name: Installing Node ${{ matrix.node-version }}
56+
uses: actions/setup-node@v3
57+
with:
58+
node-version: ${{ matrix.node-version }}
59+
60+
- name: Installing NPM packages
61+
run: |
62+
npm install -g ganache@${{ matrix.ganache-version }}
63+
64+
- name: Installing Solc compiler
65+
run: |
66+
mkdir -p ${{ github.workspace }}/build/
67+
curl -fsSL -o ${SOLC_BIN} \
68+
https://github.com/ethereum/solidity/releases/download/${{ matrix.solc-version }}/solc-static-linux
69+
chmod +x ${SOLC_BIN}
70+
71+
- name: Compiling contracts for contracts/IASRootCertMgr.sol
72+
run: |
73+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/IASRootCertMgr.sol
74+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/IASRootCertMgr.sol
75+
76+
- name: Compiling contracts for contracts/IASReportCertMgr.sol
77+
run: |
78+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/IASReportCertMgr.sol
79+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/IASReportCertMgr.sol
80+
81+
- name: Compiling contracts for contracts/DecentServerCertMgr.sol
82+
run: |
83+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/DecentServerCertMgr.sol
84+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/DecentServerCertMgr.sol
85+
86+
- name: Compiling contracts for tests/HelloWorldApp.sol
87+
run: |
88+
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/tests/HelloWorldApp.sol
89+
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/tests/HelloWorldApp.sol
90+
91+
- name: Prepare binaries for gas cost evaluation
92+
working-directory: ${{ github.workspace }}/build
93+
run: |
94+
mkdir -p contracts
95+
cp IASRootCertMgr.bin contracts/IASRootCertMgr.bin
96+
cp IASRootCertMgr.abi contracts/IASRootCertMgr.abi
97+
cp IASReportCertMgr.bin contracts/IASReportCertMgr.bin
98+
cp IASReportCertMgr.abi contracts/IASReportCertMgr.abi
99+
cp DecentServerCertMgr.bin contracts/DecentServerCertMgr.bin
100+
cp DecentServerCertMgr.abi contracts/DecentServerCertMgr.abi
101+
mkdir -p tests
102+
cp HelloWorldApp.bin tests/HelloWorldApp.bin
103+
cp HelloWorldApp.abi tests/HelloWorldApp.abi
104+
105+
- name: Run gas cost evaluation
106+
run: |
107+
python3 ${{ github.workspace }}/utils/GanacheContractTests.py eval
108+
109+
- name: Calculating checksums of the binary
110+
working-directory: ${{ github.workspace }}/build
111+
run: |
112+
sha256sum solc-static-linux >> checksums.txt
113+
sha256sum IASRootCertMgr.bin >> checksums.txt
114+
sha256sum IASRootCertMgr.abi >> checksums.txt
115+
sha256sum IASReportCertMgr.bin >> checksums.txt
116+
sha256sum IASReportCertMgr.abi >> checksums.txt
117+
sha256sum DecentServerCertMgr.bin >> checksums.txt
118+
sha256sum DecentServerCertMgr.abi >> checksums.txt
119+
sha256sum HelloWorldApp.bin >> checksums.txt
120+
sha256sum HelloWorldApp.abi >> checksums.txt
121+
122+
- name: Generate release note
123+
working-directory: ${{ github.workspace }}/build
124+
run: |
125+
echo "# Release note" >> ${RELE_NOTE}
126+
echo "" >> ${RELE_NOTE}
127+
echo "## Contracts" >> ${RELE_NOTE}
128+
echo "- contracts/IASRootCertMgr.sol" >> ${RELE_NOTE}
129+
echo "- contracts/IASReportCertMgr.sol" >> ${RELE_NOTE}
130+
echo "- contracts/DecentServerCertMgr.sol" >> ${RELE_NOTE}
131+
echo "- tests/HelloWorldApp.sol" >> ${RELE_NOTE}
132+
echo "" >> ${RELE_NOTE}
133+
echo "## Build configurations" >> ${RELE_NOTE}
134+
echo "- OS: \`${{ matrix.os }}\`" >> ${RELE_NOTE}
135+
echo "- Solc version: \`$(bash -c "${SOLC_VER_CMD}")\`" >> ${RELE_NOTE}
136+
echo "- Compiler Flags: \`${SOLC_FLAGS}\`" >> ${RELE_NOTE}
137+
echo "" >> ${RELE_NOTE}
138+
echo "## Checksums" >> ${RELE_NOTE}
139+
echo "\`\`\`" >> ${RELE_NOTE}
140+
cat checksums.txt >> ${RELE_NOTE}
141+
echo "\`\`\`" >> ${RELE_NOTE}
142+
echo "" >> ${RELE_NOTE}
143+
echo "## Gas Cost Evaluations" >> ${RELE_NOTE}
144+
echo "\`\`\`json" >> ${RELE_NOTE}
145+
cat gas_costs.json >> ${RELE_NOTE}
146+
echo "" >> ${RELE_NOTE}
147+
echo "\`\`\`" >> ${RELE_NOTE}
148+
echo "" >> ${RELE_NOTE}
149+
150+
- name: Echo release note
151+
run: |
152+
cat ${{ github.workspace }}/build/release_note.md
153+
154+
- name: Release for non-tagged commit
155+
uses: actions/upload-artifact@v3
156+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
157+
with:
158+
name: non_tagged_release
159+
path: |
160+
${{ github.workspace }}/build/release_note.md
161+
${{ github.workspace }}/build/IASRootCertMgr.bin
162+
${{ github.workspace }}/build/IASRootCertMgr.abi
163+
${{ github.workspace }}/build/IASReportCertMgr.bin
164+
${{ github.workspace }}/build/IASReportCertMgr.abi
165+
${{ github.workspace }}/build/DecentServerCertMgr.bin
166+
${{ github.workspace }}/build/DecentServerCertMgr.abi
167+
${{ github.workspace }}/build/HelloWorldApp.bin
168+
${{ github.workspace }}/build/HelloWorldApp.abi
169+
${{ github.workspace }}/build/gas_costs.json
170+
171+
- name: Release
172+
uses: softprops/action-gh-release@v1
173+
if: startsWith(github.ref, 'refs/tags/')
174+
with:
175+
body_path: ${{ github.workspace }}/build/release_note.md
176+
files: |
177+
${{ github.workspace }}/build/IASRootCertMgr.bin
178+
${{ github.workspace }}/build/IASRootCertMgr.abi
179+
${{ github.workspace }}/build/IASReportCertMgr.bin
180+
${{ github.workspace }}/build/IASReportCertMgr.abi
181+
${{ github.workspace }}/build/DecentServerCertMgr.bin
182+
${{ github.workspace }}/build/DecentServerCertMgr.abi
183+
${{ github.workspace }}/build/HelloWorldApp.bin
184+
${{ github.workspace }}/build/HelloWorldApp.abi
185+
${{ github.workspace }}/build/gas_costs.json
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Running Solidity Unit Tests for Decent RA contracts
2+
3+
4+
on:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
11+
jobs:
12+
run_sol_contracts_job:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ ubuntu-22.04 ]
17+
solc-version: [ 0.8.20 ]
18+
chain-fork: [ shanghai ]
19+
opt-runs: [ 200 ]
20+
21+
name: A job to run solidity unit tests on github actions CI
22+
steps:
23+
24+
- name: Checkout
25+
uses: actions/checkout@v3
26+
with:
27+
submodules: recursive
28+
29+
- name: Run Solidity Unit Testing for ens-contracts Tests
30+
uses: EthereumRemix/sol-test@v1.1
31+
with:
32+
test-path: 'tests/ens-contracts'
33+
compiler-version: ${{ matrix.solc-version }}
34+
optimize: true
35+
optimizer-runs: ${{ matrix.opt-runs }}
36+
hard-fork: ${{ matrix.chain-fork }}
37+
38+
- name: Run Solidity Unit Testing for RSA Tests
39+
uses: EthereumRemix/sol-test@v1.1
40+
with:
41+
test-path: 'tests/RSA'
42+
compiler-version: ${{ matrix.solc-version }}
43+
optimize: true
44+
optimizer-runs: ${{ matrix.opt-runs }}
45+
hard-fork: ${{ matrix.chain-fork }}
46+
47+
- name: Run Solidity Unit Testing for ECDSA Tests
48+
uses: EthereumRemix/sol-test@v1.1
49+
with:
50+
test-path: 'tests/Ecdsa'
51+
compiler-version: ${{ matrix.solc-version }}
52+
optimize: true
53+
optimizer-runs: ${{ matrix.opt-runs }}
54+
hard-fork: ${{ matrix.chain-fork }}
55+
56+
- name: Run Solidity Unit Testing for RLP Tests
57+
uses: EthereumRemix/sol-test@v1.1
58+
with:
59+
test-path: 'tests/RLP'
60+
compiler-version: ${{ matrix.solc-version }}
61+
optimize: true
62+
optimizer-runs: ${{ matrix.opt-runs }}
63+
hard-fork: ${{ matrix.chain-fork }}
64+
65+
- name: Run Solidity Unit Testing for x509-forest-of-trust Tests
66+
uses: EthereumRemix/sol-test@v1.1
67+
with:
68+
test-path: 'tests/x509-forest-of-trust'
69+
compiler-version: ${{ matrix.solc-version }}
70+
optimize: true
71+
optimizer-runs: ${{ matrix.opt-runs }}
72+
hard-fork: ${{ matrix.chain-fork }}
73+
74+
- name: Run Solidity Unit Testing for Decent Common Tests
75+
uses: EthereumRemix/sol-test@v1.1
76+
with:
77+
test-path: 'tests/DecentCommon'
78+
compiler-version: ${{ matrix.solc-version }}
79+
optimize: true
80+
optimizer-runs: ${{ matrix.opt-runs }}
81+
hard-fork: ${{ matrix.chain-fork }}
82+
83+
- name: Run Solidity Unit Testing for Decent IAS Tests
84+
uses: EthereumRemix/sol-test@v1.1
85+
with:
86+
test-path: 'tests/DecentIAS'
87+
compiler-version: ${{ matrix.solc-version }}
88+
optimize: true
89+
optimizer-runs: ${{ matrix.opt-runs }}
90+
hard-fork: ${{ matrix.chain-fork }}
91+
92+
- name: Run Solidity Unit Testing for Decent Server Tests
93+
uses: EthereumRemix/sol-test@v1.1
94+
with:
95+
test-path: 'tests/DecentServer'
96+
compiler-version: ${{ matrix.solc-version }}
97+
optimize: true
98+
optimizer-runs: ${{ matrix.opt-runs }}
99+
hard-fork: ${{ matrix.chain-fork }}
100+
101+
- name: Run Solidity Unit Testing for Decent App Tests
102+
uses: EthereumRemix/sol-test@v1.1
103+
with:
104+
test-path: 'tests/DecentApp'
105+
compiler-version: ${{ matrix.solc-version }}
106+
optimize: true
107+
optimizer-runs: ${{ matrix.opt-runs }}
108+
hard-fork: ${{ matrix.chain-fork }}

Makefile

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
NODEENV_CONFIG := ./utils/nodeenv.ini
2-
NODEENV_REQ := ./utils/nodeenv-requirements.txt
31
MODULES := \
42
contracts \
53
tests
4+
SOLC_VERSION := v0.8.20
5+
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
6+
CURRENT_DIR := $(dir $(MKFILE_PATH))
7+
SOLC_BIN := $(CURRENT_DIR)/build/solc-static-linux
68

79

8-
all: build/nodeenv.state $(MODULES)
10+
all: $(SOLC_BIN) $(MODULES)
911

1012

11-
build/nodeenv.state: $(NODEENV_CONFIG) $(NODEENV_REQ)
12-
which nodeenv || (echo "ERROR: nodeenv is not installed" && exit 1)
13-
nodeenv \
14-
--config=$(NODEENV_CONFIG) \
15-
--requirements=$(NODEENV_REQ) \
16-
build/nodeenv
17-
touch $@
13+
$(SOLC_BIN):
14+
mkdir -p $(dir $(SOLC_BIN)) && \
15+
curl -fsSL -o $(SOLC_BIN) \
16+
https://github.com/ethereum/solidity/releases/download/$(SOLC_VERSION)/solc-static-linux \
17+
&& \
18+
chmod +x $(SOLC_BIN)
19+
20+
21+
solc_bin: $(SOLC_BIN)
1822

1923

2024
$(MODULES):
@@ -26,7 +30,7 @@ $(addprefix clean_,$(MODULES)):
2630

2731

2832
clean: $(addprefix clean_,$(MODULES))
29-
rm -rf build/nodeenv build/nodeenv.state
33+
rm -rf $(SOLC_BIN)
3034

3135

32-
.PHONY: all clean $(MODULES) $(addprefix clean_,$(MODULES))
36+
.PHONY: all clean solc_bin $(MODULES) $(addprefix clean_,$(MODULES))

contracts/DecentAppCert.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ pragma solidity ^0.8.17;
44

55
import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
66
import {BytesUtils} from "../libs/ens-contracts/BytesUtils.sol";
7+
78
import {
89
Interface_DecentServerCertMgr
9-
} from "../contracts/Interface_DecentServerCertMgr.sol";
10+
} from "./Interface_DecentServerCertMgr.sol";
1011
import {LibSecp256k1Sha256} from "./LibSecp256k1Sha256.sol";
1112
import {OIDs} from "./Constants.sol";
1213
import {X509CertNodes} from "./X509CertNodes.sol";

contracts/DecentServerCert.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ pragma solidity ^0.8.17;
55
import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
66
import {Base64} from "../libs/base64/base64.sol";
77
import {BytesUtils} from "../libs/ens-contracts/BytesUtils.sol";
8+
import {RLPReader} from "../libs/Solidity-RLP/contracts/RLPReader.sol";
9+
810
import {IASReportCert} from "./IASReportCert.sol";
911
import {Interface_IASReportCertMgr} from "./Interface_IASReportCertMgr.sol";
1012
import {LibSecp256k1Sha256} from "./LibSecp256k1Sha256.sol";
1113
import {OIDs} from "./Constants.sol";
12-
import {RLPReader} from "../libs/Solidity-RLP/contracts/RLPReader.sol";
1314
import {X509CertNodes} from "./X509CertNodes.sol";
1415
import {X509Extension} from "./X509Extension.sol";
1516

contracts/IASReportCert.sol

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,20 @@ pragma solidity ^0.8.17;
33

44

55
import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
6-
import {OIDs, Names} from "./Constants.sol";
76
import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";
7+
8+
import {OIDs, Names} from "./Constants.sol";
89
import {X509CertNodes} from "./X509CertNodes.sol";
910
import {X509Name} from "./X509Name.sol";
11+
import {X509Timestamp} from "./X509Timestamp.sol";
1012

1113

1214
library IASReportCert {
1315

1416
using Asn1Decode for bytes;
1517
using X509CertNodes for X509CertNodes.CertNodesObj;
1618
using X509CertNodes for X509CertNodes.CertTbsNodesObj;
19+
using X509Timestamp for X509CertNodes.CertTbsNodesObj;
1720

1821
//===== constants =====
1922

contracts/IASReportCertMgr.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
pragma solidity ^0.8.17;
33

44

5+
import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";
6+
57
import {Interface_IASRootCertMgr} from "./Interface_IASRootCertMgr.sol";
68
import {IASReportCert} from "./IASReportCert.sol";
7-
import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";
89
import {X509CertNodes} from "./X509CertNodes.sol";
910

1011

0 commit comments

Comments
 (0)