-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TrustEVM Contract CI #293
TrustEVM Contract CI #293
Changes from 38 commits
5ef46db
a983ca9
9cf20e0
319053e
9c668bc
e3024b8
4a9e78d
725692a
2704bb3
1f54dde
4d0f259
542baf0
847aada
6c983ed
af86cf4
fe4393f
e4653d6
f33007b
16f8456
666015b
6cd472e
2967aa7
553ef03
f0d6bbe
2cb3f3f
ac64793
9d58dd0
8296ef9
c711f72
1977b19
5d06610
9d5f728
63f7030
dd5c51a
2f4e298
f82e153
fc5d8c8
51590e9
1b7ff4e
7d4ae3a
87d6b7e
2d3ecc9
4d3f8e9
b276a7d
2314df6
bfa6f68
53a7dd0
a06d4ed
1305944
5752dd3
5cbe3b5
7239da9
582dcef
d89596b
f782e44
08bad50
68474bc
abf0a46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# print and run a command | ||
function ee() | ||
{ | ||
echo "$ $*" | ||
eval "$@" | ||
} | ||
|
||
export Deosio_DIR='/usr/lib/x86_64-linux-gnu/cmake/eosio' | ||
# debug code | ||
ee cmake --version | ||
echo 'Leap version:' | ||
cat "$Deosio_DIR/EosioTester.cmake" | grep 'EOSIO_VERSION' | grep -oP "['\"].*['\"]" | tr -d "'\"" || : | ||
|
||
# build | ||
ee mkdir -p contract/tests/build | ||
ee pushd contract/tests | ||
ee pushd build | ||
ee "cmake -Deosio_DIR=$Deosio_DIR .." | ||
ee make -j "$(nproc)" unit_test | ||
|
||
# pack | ||
ee popd | ||
ee 'tar -czf ../../contract-test.tar.gz build/*' | ||
ee popd | ||
|
||
echo "Done! - ${0##*/}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# print and run a command | ||
function ee() | ||
{ | ||
echo "$ $*" | ||
eval "$@" | ||
} | ||
|
||
# debug code | ||
ee cdt-cc --version | ||
ee cmake --version | ||
|
||
# build | ||
ee mkdir -p contract/build | ||
ee pushd contract | ||
ee pushd build | ||
ee cmake -DCMAKE_BUILD_TYPE=Release -DWITH_TEST_ACTIONS=On .. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should build the contract once w/o test actions, and once with test actions. It's okay that we only test the one with test actions, but the non-test action build is the one we'd deploy so it's nice to make sure that it's at least building successfully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree with @spoonincode. maybe we can add build-contract-release.sh? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. No need to duplicate the BASH script, I abstracted the |
||
ee make -j "$(nproc)" | ||
|
||
# pack | ||
ee popd | ||
ee 'tar -czf ../contract.tar.gz build/*' | ||
ee popd | ||
|
||
echo "Done! - ${0##*/}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# TrustEVM Contract CI | ||
This GitHub Actions workflow builds the TrustEVM contract and its associated tests. | ||
|
||
### Index | ||
1. [Triggers](#triggers) | ||
1. [Inputs](#inputs) | ||
1. [Steps](#steps) | ||
1. [Outputs](#outputs) | ||
1. [GitHub App Integration](#github-app-integration) | ||
1. [See Also](#see-also) | ||
|
||
## Triggers | ||
This GitHub action will run under the following circumstances: | ||
1. When code is pushed to the `main` branch. | ||
1. When code is pushed to any branch with a name starting with `release/`. | ||
1. Workflow dispatch event, which is triggered manually using the "Workflow Dispatch" button in the Actions tab of the GitHub repository. | ||
|
||
## Inputs | ||
The inputs for this GitHub action are: | ||
1. `TRUSTEVM_CI_APP_ID` - the app ID of the `trustevm-ci-submodule-checkout` GitHub App. | ||
1. `TRUSTEVM_CI_APP_KEY` - the private key to the `trustevm-ci-submodule-checkout` GitHub App. | ||
1. `GITHUB_TOKEN` - a GitHub Actions intrinsic used to access the repository and other public resources. | ||
|
||
These inputs are used in various steps of the workflow to perform actions such as authentication, downloading artifacts, and uploading artifacts. | ||
|
||
## Steps | ||
This workflow performs the following steps: | ||
1. Authenticate to the `trustevm-ci-submodule-checkout` GitHub app using the [AntelopeIO/github-app-token-action](https://github.com/AntelopeIO/github-app-token-action) action to obtain an ephemeral token. | ||
1. Checkout the repo and submodules using the ephemeral token. | ||
1. Attach an annotation to the build with CI documentation. | ||
1. Download the CDT binary using the [AntelopeIO/asset-artifact-download-action](https://github.com/AntelopeIO/asset-artifact-download-action) action. | ||
1. Install the CDT binary. | ||
1. Build the TrustEVM contract using `make` and `cmake`. | ||
1. Upload the contract build folder to GitHub Actions. | ||
1. Download the `leap-dev` binary using [AntelopeIO/asset-artifact-download-action](https://github.com/AntelopeIO/asset-artifact-download-action) action. | ||
1. Install the `leap-dev` binary. | ||
1. Build the TrustEVM contract tests using `make` and `cmake`. | ||
1. Upload the build folder for the contract test code to GitHub Actions. | ||
|
||
## Outputs | ||
This workflow produces the following outputs: | ||
1. Contract Build Artifacts - `contract.tar.gz` containing the built contract from the `contract/build` folder. | ||
1. Contract Test Artifacts - `contract-test.tar.gz` containing the built contract test artifacts from the `contract/tests/build` folder. | ||
|
||
Note that, due to actions/upload-artifact [issue 39](https://github.com/actions/upload-artifact/issues/39) which has been open for over _three years_ and counting, the archives attached as artifacts will be zipped by GitHub when you download them such that you get a `*.zip` containing the `*.tar.gz`. There is nothing anyone can do about this except for GitHub. | ||
|
||
## GitHub App Integration | ||
This workflow uses the [AntelopeIO/github-app-token-action](https://github.com/AntelopeIO/github-app-token-action) GitHub action to assume the role of a GitHub application installed to the AntelopeIO organization to clone the private submodules. It requests a token from the GitHub app, clones everything using this token under the identity of the app, then the token expires. This is advantageous over a persistent API key from a GitHub service account because this does not consume a paid user seat, the "account" associated with the app cannot be logged into in the GitHub web UI, the app is scoped to exactly the permissions it needs to perform the clones for this repo _and nothing more_, and the API key expires very quickly so a bad actor who exfiltrates this key from the CI system should find it is not useful. | ||
|
||
**The downside is that if TrustEVM adds additional private submodules, the GitHub app must be granted permissions to these new submodules.** The CI system will not work until this happens. | ||
|
||
## See Also | ||
- [asset-artifact-download-action](https://github.com/AntelopeIO/asset-artifact-download-action) GitHub Action | ||
- [github-app-token-action](https://github.com/AntelopeIO/github-app-token-action) GitHub action | ||
- [TrustEVM Documentation](../../README.md) | ||
|
||
For assistance with the CI system, please open an issue in this repo or reach out in the `#help-automation` channel via IM. | ||
|
||
*** | ||
**_Legal notice_** | ||
This document was generated in collaboration with ChatGPT from OpenAI, a machine learning algorithm or weak artificial intelligence (AI). At the time of this writing, the [OpenAI terms of service agreement](https://openai.com/terms) §3.a states: | ||
> Your Content. You may provide input to the Services (“Input”), and receive output generated and returned by the Services based on the Input (“Output”). Input and Output are collectively “Content.” As between the parties and to the extent permitted by applicable law, you own all Input, and subject to your compliance with these Terms, OpenAI hereby assigns to you all its right, title and interest in and to Output. | ||
|
||
This notice is required in some countries. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: TrustEVM Contract CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- release/* | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: TrustEVM Contract Build | ||
runs-on: ubuntu-20.04 | ||
env: | ||
CC: gcc-10 | ||
CXX: g++-10 | ||
|
||
steps: | ||
- name: Authenticate | ||
id: auth | ||
uses: AntelopeIO/github-app-token-action@v1 | ||
with: | ||
app_id: ${{ secrets.TRUSTEVM_CI_APP_ID }} | ||
private_key: ${{ secrets.TRUSTEVM_CI_APP_KEY }} | ||
|
||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
submodules: 'recursive' | ||
token: ${{ steps.auth.outputs.token }} | ||
|
||
- name: Attach Documentation | ||
run: cat .github/workflows/contract.md >> $GITHUB_STEP_SUMMARY | ||
|
||
- name: Download CDT | ||
uses: AntelopeIO/asset-artifact-download-action@v2 | ||
with: | ||
owner: AntelopeIO | ||
repo: cdt | ||
target: 'v3.1.0' | ||
prereleases: false | ||
file: 'cdt_.*amd64.deb' | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install CDT | ||
run: sudo apt-get install -y ./cdt*.deb | ||
|
||
- name: Build TrustEVM Contract | ||
run: .github/workflows/build-contract.sh | ||
|
||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: contract.tar.gz | ||
path: contract.tar.gz | ||
if-no-files-found: error | ||
|
||
- name: Download Leap - dev binary | ||
uses: AntelopeIO/asset-artifact-download-action@v2 | ||
with: | ||
owner: AntelopeIO | ||
repo: leap | ||
target: 'v3.1.3' | ||
prereleases: false | ||
file: 'leap-dev.*(x86_64|amd64).deb' | ||
container-package: experimental-binaries | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Install Leap | ||
run: sudo apt-get install -y ./leap*.deb | ||
|
||
- name: Build TrustEVM Contract Tests | ||
run: .github/workflows/build-contract-test.sh | ||
|
||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: contract-test.tar.gz | ||
path: contract-test.tar.gz | ||
if-no-files-found: error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend adding
-DCMAKE_BUILD_TYPE=Release
. It shouldn't matter much, but every little bit helps.Also, did you need the
-Deosio_DIR
thing? afaik that should not be requiredThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually just tested, the difference is more on the order of 25%, so highly recommend doing Release here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not, though my previous testing had indicated otherwise. Removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Thank you!