-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from lsd-ucsc/add-github-actions
- Added unit test actions - Added create release actions
- Loading branch information
Showing
5 changed files
with
459 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,302 @@ | ||
name: Create release | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
tags: | ||
- "v*.*.*" | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
create_release: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-22.04 ] | ||
|
||
python-version: [ 3.11 ] | ||
node-version: [ 18.16.0 ] | ||
|
||
ganache-version: [ 7.8.0 ] | ||
|
||
solc-version: [ v0.8.20 ] | ||
|
||
env: | ||
SOLC_BIN: ${{ github.workspace }}/build/solc-static-linux | ||
SOLC_FLAGS: >- | ||
--optimize --optimize-runs 200 | ||
--revert-strings strip | ||
--via-ir | ||
--overwrite | ||
--base-path ${{ github.workspace }} | ||
--output-dir ${{ github.workspace }}/build/ | ||
SOLC_VER_CMD: >- | ||
${{ github.workspace }}/build/solc-static-linux | ||
--version | tail -n 1 | sed -e "s/^Version: //g" | ||
RELE_NOTE: ${{ github.workspace }}/build/release_note.md | ||
DECENT_PUBSUB_VER: v0.1.6 | ||
DECENT_RA_VER: v0.0.1 | ||
|
||
name: A job to create a release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.ACCESS_APP_TOKEN }} | ||
submodules: recursive | ||
|
||
- name: Installing Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Installing Python packages | ||
run: | | ||
python3 -m pip install --requirement ${{ github.workspace }}/utils/gas_cost_eval_requirements.txt | ||
- name: Installing GitHubApiHelper | ||
run: | | ||
python3 -m pip install git+https://github.com/zhenghaven/[email protected] | ||
- name: Installing Node ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Installing NPM packages | ||
run: | | ||
npm install -g ganache@${{ matrix.ganache-version }} | ||
- name: Installing Solc compiler | ||
run: | | ||
mkdir -p ${{ github.workspace }}/build/ | ||
curl -fsSL -o ${SOLC_BIN} \ | ||
https://github.com/ethereum/solidity/releases/download/${{ matrix.solc-version }}/solc-static-linux | ||
chmod +x ${SOLC_BIN} | ||
- name: Compiling contracts for DecentRevoker/RevokerByVoting.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/DecentRevoker/RevokerByVoting.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/DecentRevoker/RevokerByVoting.sol | ||
- name: Compiling contracts for DecentRevoker/RevokerByConflictMsg.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/DecentRevoker/RevokerByConflictMsg.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/DecentRevoker/RevokerByConflictMsg.sol | ||
- name: Compiling contracts for DecentRevoker/RevokerByLeakedKey.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/DecentRevoker/RevokerByLeakedKey.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/DecentRevoker/RevokerByLeakedKey.sol | ||
- name: Compiling contracts for KeyRevoker/KeyRevokerByVoting.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/KeyRevoker/KeyRevokerByVoting.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/KeyRevoker/KeyRevokerByVoting.sol | ||
- name: Compiling contracts for KeyRevoker/KeyRevokerByConflictMsg.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/KeyRevoker/KeyRevokerByConflictMsg.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/KeyRevoker/KeyRevokerByConflictMsg.sol | ||
- name: Compiling contracts for KeyRevoker/KeyRevokerByLeakedKey.sol | ||
run: | | ||
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/KeyRevoker/KeyRevokerByLeakedKey.sol | ||
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/KeyRevoker/KeyRevokerByLeakedKey.sol | ||
- name: Calculating checksums of the binary | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
sha256sum solc-static-linux >> checksums.txt | ||
sha256sum RevokerByVoting.bin >> checksums.txt | ||
sha256sum RevokerByVoting.abi >> checksums.txt | ||
sha256sum RevokerByConflictMsg.bin >> checksums.txt | ||
sha256sum RevokerByConflictMsg.abi >> checksums.txt | ||
sha256sum RevokerByLeakedKey.bin >> checksums.txt | ||
sha256sum RevokerByLeakedKey.abi >> checksums.txt | ||
sha256sum KeyRevokerByVoting.bin >> checksums.txt | ||
sha256sum KeyRevokerByVoting.abi >> checksums.txt | ||
sha256sum KeyRevokerByConflictMsg.abi >> checksums.txt | ||
sha256sum KeyRevokerByConflictMsg.abi >> checksums.txt | ||
sha256sum KeyRevokerByLeakedKey.abi >> checksums.txt | ||
sha256sum KeyRevokerByLeakedKey.abi >> checksums.txt | ||
- name: Prepare binaries for gas cost evaluation | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
mkdir -p DecentRevoker | ||
cp RevokerByVoting.bin DecentRevoker/RevokerByVoting.bin | ||
cp RevokerByVoting.abi DecentRevoker/RevokerByVoting.abi | ||
cp RevokerByConflictMsg.bin DecentRevoker/RevokerByConflictMsg.bin | ||
cp RevokerByConflictMsg.abi DecentRevoker/RevokerByConflictMsg.abi | ||
cp RevokerByLeakedKey.bin DecentRevoker/RevokerByLeakedKey.bin | ||
cp RevokerByLeakedKey.abi DecentRevoker/RevokerByLeakedKey.abi | ||
mkdir -p KeyRevoker | ||
cp KeyRevokerByVoting.bin KeyRevoker/KeyRevokerByVoting.bin | ||
cp KeyRevokerByVoting.abi KeyRevoker/KeyRevokerByVoting.abi | ||
cp KeyRevokerByConflictMsg.bin KeyRevoker/KeyRevokerByConflictMsg.bin | ||
cp KeyRevokerByConflictMsg.abi KeyRevoker/KeyRevokerByConflictMsg.abi | ||
cp KeyRevokerByLeakedKey.bin KeyRevoker/KeyRevokerByLeakedKey.bin | ||
cp KeyRevokerByLeakedKey.abi KeyRevoker/KeyRevokerByLeakedKey.abi | ||
- name: Downloading built contracts for DecentPubSub | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ACCESS_APP_TOKEN }} | ||
run: | | ||
mkdir -p ${{ github.workspace }}/libs/DecentPubSub/build/PubSub/ | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_PUBSUB_VER} \ | ||
--asset PubSubService.bin \ | ||
--save-path ${{ github.workspace }}/libs/DecentPubSub/build/PubSub/PubSubService.bin \ | ||
--repo lsd-ucsc/decent-pubsub-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_PUBSUB_VER} \ | ||
--asset PubSubService.abi \ | ||
--save-path ${{ github.workspace }}/libs/DecentPubSub/build/PubSub/PubSubService.abi \ | ||
--repo lsd-ucsc/decent-pubsub-onchain | ||
sha256sum ${{ github.workspace }}/libs/DecentPubSub/build/PubSub/PubSubService.bin | ||
sha256sum ${{ github.workspace }}/libs/DecentPubSub/build/PubSub/PubSubService.abi | ||
- name: Downloading built contracts for DecentRA | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.ACCESS_APP_TOKEN }} | ||
run: | | ||
mkdir -p ${{ github.workspace }}/libs/DecentRA/build/contracts/ | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset IASRootCertMgr.bin \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/IASRootCertMgr.bin \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset IASRootCertMgr.abi \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/IASRootCertMgr.abi \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset IASReportCertMgr.bin \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/IASReportCertMgr.bin \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset IASReportCertMgr.abi \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/IASReportCertMgr.abi \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset DecentServerCertMgr.bin \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/DecentServerCertMgr.bin \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
python3 -m GitHubApiHelper --auth-token \ | ||
api_release_asset_dl \ | ||
--version ${DECENT_RA_VER} \ | ||
--asset DecentServerCertMgr.abi \ | ||
--save-path ${{ github.workspace }}/libs/DecentRA/build/contracts/DecentServerCertMgr.abi \ | ||
--repo lsd-ucsc/decent-ra-onchain | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/IASRootCertMgr.bin | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/IASRootCertMgr.abi | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/IASReportCertMgr.bin | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/IASReportCertMgr.abi | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/DecentServerCertMgr.bin | ||
sha256sum ${{ github.workspace }}/libs/DecentRA/build/contracts/DecentServerCertMgr.abi | ||
- name: Run gas cost evaluation for DecentRevoker | ||
run: | | ||
python3 ${{ github.workspace }}/utils/GasEvalDecentRevoker.py | ||
- name: Run gas cost evaluation for KeyRevoker | ||
run: | | ||
python3 ${{ github.workspace }}/utils/GasEvalKeyRevoker.py | ||
- name: Generate release note | ||
working-directory: ${{ github.workspace }}/build | ||
run: | | ||
echo "# Release note" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "## Contracts" >> ${RELE_NOTE} | ||
echo "- DecentRevoker/RevokerByVoting.sol" >> ${RELE_NOTE} | ||
echo "- DecentRevoker/RevokerByConflictMsg.sol" >> ${RELE_NOTE} | ||
echo "- DecentRevoker/RevokerByLeakedKey.sol" >> ${RELE_NOTE} | ||
echo "- KeyRevoker/KeyRevokerByVoting.sol" >> ${RELE_NOTE} | ||
echo "- KeyRevoker/KeyRevokerByConflictMsg.sol" >> ${RELE_NOTE} | ||
echo "- KeyRevoker/KeyRevokerByLeakedKey.sol" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "## Build configurations" >> ${RELE_NOTE} | ||
echo "- OS: \`${{ matrix.os }}\`" >> ${RELE_NOTE} | ||
echo "- Solc version: \`$(bash -c "${SOLC_VER_CMD}")\`" >> ${RELE_NOTE} | ||
echo "- Compiler Flags: \`${SOLC_FLAGS}\`" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "## Checksums" >> ${RELE_NOTE} | ||
echo "\`\`\`" >> ${RELE_NOTE} | ||
cat checksums.txt >> ${RELE_NOTE} | ||
echo "\`\`\`" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "## Gas Cost Evaluations" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "### Decent Revoker" >> ${RELE_NOTE} | ||
echo "\`\`\`json" >> ${RELE_NOTE} | ||
cat gas_cost_decent_revoker.json >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "\`\`\`" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "### Key Revoker" >> ${RELE_NOTE} | ||
echo "\`\`\`json" >> ${RELE_NOTE} | ||
cat gas_cost_key_revoker.json >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
echo "\`\`\`" >> ${RELE_NOTE} | ||
echo "" >> ${RELE_NOTE} | ||
- name: Echo release note | ||
run: | | ||
cat ${{ github.workspace }}/build/release_note.md | ||
- name: Release for non-tagged commit | ||
uses: actions/upload-artifact@v3 | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
with: | ||
name: non_tagged_release | ||
path: | | ||
${{ github.workspace }}/build/release_note.md | ||
${{ github.workspace }}/build/RevokerByVoting.bin | ||
${{ github.workspace }}/build/RevokerByVoting.abi | ||
${{ github.workspace }}/build/RevokerByConflictMsg.bin | ||
${{ github.workspace }}/build/RevokerByConflictMsg.abi | ||
${{ github.workspace }}/build/RevokerByLeakedKey.bin | ||
${{ github.workspace }}/build/RevokerByLeakedKey.abi | ||
${{ github.workspace }}/build/KeyRevokerByVoting.bin | ||
${{ github.workspace }}/build/KeyRevokerByVoting.abi | ||
${{ github.workspace }}/build/KeyRevokerByConflictMsg.bin | ||
${{ github.workspace }}/build/KeyRevokerByConflictMsg.abi | ||
${{ github.workspace }}/build/KeyRevokerByLeakedKey.bin | ||
${{ github.workspace }}/build/KeyRevokerByLeakedKey.abi | ||
${{ github.workspace }}/build/gas_cost_decent_revoker.json | ||
${{ github.workspace }}/build/gas_cost_key_revoker.json | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
body_path: ${{ github.workspace }}/build/release_note.md | ||
files: | | ||
${{ github.workspace }}/build/RevokerByVoting.bin | ||
${{ github.workspace }}/build/RevokerByVoting.abi | ||
${{ github.workspace }}/build/RevokerByConflictMsg.bin | ||
${{ github.workspace }}/build/RevokerByConflictMsg.abi | ||
${{ github.workspace }}/build/RevokerByLeakedKey.bin | ||
${{ github.workspace }}/build/RevokerByLeakedKey.abi | ||
${{ github.workspace }}/build/KeyRevokerByVoting.bin | ||
${{ github.workspace }}/build/KeyRevokerByVoting.abi | ||
${{ github.workspace }}/build/KeyRevokerByConflictMsg.bin | ||
${{ github.workspace }}/build/KeyRevokerByConflictMsg.abi | ||
${{ github.workspace }}/build/KeyRevokerByLeakedKey.bin | ||
${{ github.workspace }}/build/KeyRevokerByLeakedKey.abi | ||
${{ github.workspace }}/build/gas_cost_decent_revoker.json | ||
${{ github.workspace }}/build/gas_cost_key_revoker.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Running Solidity Unit Tests for Decent Revoker contracts | ||
|
||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
|
||
jobs: | ||
run_sol_contracts_job: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-22.04 ] | ||
solc-version: [ 0.8.20 ] | ||
chain-fork: [ shanghai ] | ||
opt-runs: [ 200 ] | ||
|
||
name: A job to run solidity unit tests on github actions CI | ||
steps: | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.ACCESS_APP_TOKEN }} | ||
submodules: recursive | ||
|
||
- name: Run Solidity Unit Testing for DecentRevoker Tests | ||
uses: EthereumRemix/[email protected] | ||
with: | ||
test-path: 'tests/DecentRevoker' | ||
compiler-version: ${{ matrix.solc-version }} | ||
optimize: true | ||
optimizer-runs: ${{ matrix.opt-runs }} | ||
hard-fork: ${{ matrix.chain-fork }} | ||
|
||
- name: Run Solidity Unit Testing for KeyRevoker Tests | ||
uses: EthereumRemix/[email protected] | ||
with: | ||
test-path: 'tests/KeyRevoker' | ||
compiler-version: ${{ matrix.solc-version }} | ||
optimize: true | ||
optimizer-runs: ${{ matrix.opt-runs }} | ||
hard-fork: ${{ matrix.chain-fork }} |
Submodule DecentPubSub
updated
19 files
+169 −86 | .github/workflows/create-release.yaml | |
+0 −64 | .github/workflows/pubsub-build.yaml | |
+12 −3 | .github/workflows/pubsub-solidity-unittesting.yaml | |
+0 −64 | .github/workflows/tests-build.yaml | |
+4 −0 | .gitmodules | |
+16 −8 | Makefile | |
+32 −25 | PubSub/EventManager.sol | |
+33 −33 | PubSub/Makefile | |
+136 −0 | tests/GasCostEvalDeploy.py | |
+108 −73 | tests/GasCostEvalMultiPubs.py | |
+56 −48 | tests/GasCostEvalMultiSubs.py | |
+257 −0 | tests/GasCostEvalPlot.py | |
+2 −9 | tests/HelloWorldSubscriber.sol | |
+33 −33 | tests/Makefile | |
+0 −586 | utils/EthContractHelper.py | |
+1 −0 | utils/PyEthHelper | |
+0 −1 | utils/ganache_keys.json | |
+0 −46 | utils/ganache_keys_checksum.json | |
+7 −0 | utils/gas_cost_eval_requirements.txt |
Oops, something went wrong.