Skip to content

Commit

Permalink
Merge pull request #1 from lsd-ucsc/adding-github-actions
Browse files Browse the repository at this point in the history
- Added GitHub Actions for
  - Unit testing
  - Version release
  • Loading branch information
zhenghaven authored May 13, 2023
2 parents 47cc7df + 61d6146 commit be2e60b
Show file tree
Hide file tree
Showing 43 changed files with 1,097 additions and 413 deletions.
185 changes: 185 additions & 0 deletions .github/workflows/create-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
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

name: A job to create a release
steps:
- name: Checkout
uses: actions/checkout@v3
with:
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 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 contracts/IASRootCertMgr.sol
run: |
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/IASRootCertMgr.sol
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/IASRootCertMgr.sol
- name: Compiling contracts for contracts/IASReportCertMgr.sol
run: |
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/IASReportCertMgr.sol
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/IASReportCertMgr.sol
- name: Compiling contracts for contracts/DecentServerCertMgr.sol
run: |
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/contracts/DecentServerCertMgr.sol
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/contracts/DecentServerCertMgr.sol
- name: Compiling contracts for tests/HelloWorldApp.sol
run: |
${SOLC_BIN} ${SOLC_FLAGS} --bin ${{ github.workspace }}/tests/HelloWorldApp.sol
${SOLC_BIN} ${SOLC_FLAGS} --abi ${{ github.workspace }}/tests/HelloWorldApp.sol
- name: Prepare binaries for gas cost evaluation
working-directory: ${{ github.workspace }}/build
run: |
mkdir -p contracts
cp IASRootCertMgr.bin contracts/IASRootCertMgr.bin
cp IASRootCertMgr.abi contracts/IASRootCertMgr.abi
cp IASReportCertMgr.bin contracts/IASReportCertMgr.bin
cp IASReportCertMgr.abi contracts/IASReportCertMgr.abi
cp DecentServerCertMgr.bin contracts/DecentServerCertMgr.bin
cp DecentServerCertMgr.abi contracts/DecentServerCertMgr.abi
mkdir -p tests
cp HelloWorldApp.bin tests/HelloWorldApp.bin
cp HelloWorldApp.abi tests/HelloWorldApp.abi
- name: Run gas cost evaluation
run: |
python3 ${{ github.workspace }}/utils/GanacheContractTests.py eval
- name: Calculating checksums of the binary
working-directory: ${{ github.workspace }}/build
run: |
sha256sum solc-static-linux >> checksums.txt
sha256sum IASRootCertMgr.bin >> checksums.txt
sha256sum IASRootCertMgr.abi >> checksums.txt
sha256sum IASReportCertMgr.bin >> checksums.txt
sha256sum IASReportCertMgr.abi >> checksums.txt
sha256sum DecentServerCertMgr.bin >> checksums.txt
sha256sum DecentServerCertMgr.abi >> checksums.txt
sha256sum HelloWorldApp.bin >> checksums.txt
sha256sum HelloWorldApp.abi >> checksums.txt
- name: Generate release note
working-directory: ${{ github.workspace }}/build
run: |
echo "# Release note" >> ${RELE_NOTE}
echo "" >> ${RELE_NOTE}
echo "## Contracts" >> ${RELE_NOTE}
echo "- contracts/IASRootCertMgr.sol" >> ${RELE_NOTE}
echo "- contracts/IASReportCertMgr.sol" >> ${RELE_NOTE}
echo "- contracts/DecentServerCertMgr.sol" >> ${RELE_NOTE}
echo "- tests/HelloWorldApp.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 "\`\`\`json" >> ${RELE_NOTE}
cat gas_costs.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/IASRootCertMgr.bin
${{ github.workspace }}/build/IASRootCertMgr.abi
${{ github.workspace }}/build/IASReportCertMgr.bin
${{ github.workspace }}/build/IASReportCertMgr.abi
${{ github.workspace }}/build/DecentServerCertMgr.bin
${{ github.workspace }}/build/DecentServerCertMgr.abi
${{ github.workspace }}/build/HelloWorldApp.bin
${{ github.workspace }}/build/HelloWorldApp.abi
${{ github.workspace }}/build/gas_costs.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/IASRootCertMgr.bin
${{ github.workspace }}/build/IASRootCertMgr.abi
${{ github.workspace }}/build/IASReportCertMgr.bin
${{ github.workspace }}/build/IASReportCertMgr.abi
${{ github.workspace }}/build/DecentServerCertMgr.bin
${{ github.workspace }}/build/DecentServerCertMgr.abi
${{ github.workspace }}/build/HelloWorldApp.bin
${{ github.workspace }}/build/HelloWorldApp.abi
${{ github.workspace }}/build/gas_costs.json
108 changes: 108 additions & 0 deletions .github/workflows/solidity-unittesting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Running Solidity Unit Tests for Decent RA 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:
submodules: recursive

- name: Run Solidity Unit Testing for ens-contracts Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/ens-contracts'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for RSA Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/RSA'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for ECDSA Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/Ecdsa'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for RLP Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/RLP'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for x509-forest-of-trust Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/x509-forest-of-trust'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for Decent Common Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/DecentCommon'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for Decent IAS Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/DecentIAS'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for Decent Server Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/DecentServer'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}

- name: Run Solidity Unit Testing for Decent App Tests
uses: EthereumRemix/sol-test@v1.1
with:
test-path: 'tests/DecentApp'
compiler-version: ${{ matrix.solc-version }}
optimize: true
optimizer-runs: ${{ matrix.opt-runs }}
hard-fork: ${{ matrix.chain-fork }}
28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
NODEENV_CONFIG := ./utils/nodeenv.ini
NODEENV_REQ := ./utils/nodeenv-requirements.txt
MODULES := \
contracts \
tests
SOLC_VERSION := v0.8.20
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
CURRENT_DIR := $(dir $(MKFILE_PATH))
SOLC_BIN := $(CURRENT_DIR)/build/solc-static-linux


all: build/nodeenv.state $(MODULES)
all: $(SOLC_BIN) $(MODULES)


build/nodeenv.state: $(NODEENV_CONFIG) $(NODEENV_REQ)
which nodeenv || (echo "ERROR: nodeenv is not installed" && exit 1)
nodeenv \
--config=$(NODEENV_CONFIG) \
--requirements=$(NODEENV_REQ) \
build/nodeenv
touch $@
$(SOLC_BIN):
mkdir -p $(dir $(SOLC_BIN)) && \
curl -fsSL -o $(SOLC_BIN) \
https://github.com/ethereum/solidity/releases/download/$(SOLC_VERSION)/solc-static-linux \
&& \
chmod +x $(SOLC_BIN)


solc_bin: $(SOLC_BIN)


$(MODULES):
Expand All @@ -26,7 +30,7 @@ $(addprefix clean_,$(MODULES)):


clean: $(addprefix clean_,$(MODULES))
rm -rf build/nodeenv build/nodeenv.state
rm -rf $(SOLC_BIN)


.PHONY: all clean $(MODULES) $(addprefix clean_,$(MODULES))
.PHONY: all clean solc_bin $(MODULES) $(addprefix clean_,$(MODULES))
3 changes: 2 additions & 1 deletion contracts/DecentAppCert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ pragma solidity ^0.8.17;

import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
import {BytesUtils} from "../libs/ens-contracts/BytesUtils.sol";

import {
Interface_DecentServerCertMgr
} from "../contracts/Interface_DecentServerCertMgr.sol";
} from "./Interface_DecentServerCertMgr.sol";
import {LibSecp256k1Sha256} from "./LibSecp256k1Sha256.sol";
import {OIDs} from "./Constants.sol";
import {X509CertNodes} from "./X509CertNodes.sol";
Expand Down
3 changes: 2 additions & 1 deletion contracts/DecentServerCert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ pragma solidity ^0.8.17;
import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
import {Base64} from "../libs/base64/base64.sol";
import {BytesUtils} from "../libs/ens-contracts/BytesUtils.sol";
import {RLPReader} from "../libs/Solidity-RLP/contracts/RLPReader.sol";

import {IASReportCert} from "./IASReportCert.sol";
import {Interface_IASReportCertMgr} from "./Interface_IASReportCertMgr.sol";
import {LibSecp256k1Sha256} from "./LibSecp256k1Sha256.sol";
import {OIDs} from "./Constants.sol";
import {RLPReader} from "../libs/Solidity-RLP/contracts/RLPReader.sol";
import {X509CertNodes} from "./X509CertNodes.sol";
import {X509Extension} from "./X509Extension.sol";

Expand Down
5 changes: 4 additions & 1 deletion contracts/IASReportCert.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ pragma solidity ^0.8.17;


import {Asn1Decode} from "../libs/asn1-decode/Asn1Decode.sol";
import {OIDs, Names} from "./Constants.sol";
import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";

import {OIDs, Names} from "./Constants.sol";
import {X509CertNodes} from "./X509CertNodes.sol";
import {X509Name} from "./X509Name.sol";
import {X509Timestamp} from "./X509Timestamp.sol";


library IASReportCert {

using Asn1Decode for bytes;
using X509CertNodes for X509CertNodes.CertNodesObj;
using X509CertNodes for X509CertNodes.CertTbsNodesObj;
using X509Timestamp for X509CertNodes.CertTbsNodesObj;

//===== constants =====

Expand Down
3 changes: 2 additions & 1 deletion contracts/IASReportCertMgr.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
pragma solidity ^0.8.17;


import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";

import {Interface_IASRootCertMgr} from "./Interface_IASRootCertMgr.sol";
import {IASReportCert} from "./IASReportCert.sol";
import {LibRsaSha256} from "../libs/sig-verify-algs/LibRsaSha256.sol";
import {X509CertNodes} from "./X509CertNodes.sol";


Expand Down
Loading

0 comments on commit be2e60b

Please sign in to comment.