Skip to content

Commit

Permalink
Use new release flow. (#587)
Browse files Browse the repository at this point in the history
* Use new release flow.

* Upload zip, as well.

* Update actions.yml.

* Do not upload zip artifacts.
  • Loading branch information
andreibancioiu authored Nov 24, 2022
1 parent 5eaf7d6 commit 00a5979
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 131 deletions.
120 changes: 17 additions & 103 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -1,109 +1,23 @@
name: Builds and tests
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
wasm_test:
name: Wasm tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
default: true
toolchain: nightly
- name: Install erdpy and vmtools
run : |
source .github/workflows/env
pip3 install erdpy
mkdir $HOME/elrondsdk
erdpy config set dependencies.vmtools.tag v1.4.32
erdpy deps install vmtools
erdpy config set dependencies.rust.tag nightly-2021-11-04
erdpy deps install rust
sudo apt install binaryen
- name: Build the wasm contracts
run: |
source .github/workflows/env
./build-wasm.sh
./wasm-opt.sh
- name: Run VM tests
run: |
source .github/workflows/env
cargo test --features elrond-wasm-debug/mandos-go-tests
- name: Generate file size report
run: |
source .github/workflows/env
./sizes.sh > sizes.txt
- name: Upload file size report
uses: actions/upload-artifact@v2
with:
name: sizes
path: sizes.txt
- name: Download base report
uses: dawidd6/action-download-artifact@v2
if: ${{ github.event_name == 'pull_request' }}
continue-on-error: true
with:
workflow: actions.yml
name: sizes
commit: ${{github.event.pull_request.base.sha}}
path: base-sizes
- name: Generate report
id: sizes-report
if: ${{ github.event_name == 'pull_request' }}
run: |
source .github/workflows/env
python tools/size-report/size_report.py base-sizes/sizes.txt sizes.txt --allow-missing > report.md
- name: Render report
id: template
uses: chuhlomin/[email protected]
if: ${{ github.event_name == 'pull_request' }}
with:
template: report.md
vars: |
base: ${{github.event.pull_request.base.sha}}
head: ${{github.event.pull_request.head.sha}}
- name: Find sizes report comment
id: fc
uses: peter-evans/find-comment@v1
if: ${{ github.event_name == 'pull_request' }}
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: Contract file size comparison
- name: Create or update sizes report comment
uses: peter-evans/create-or-update-comment@v1
if: ${{ github.event_name == 'pull_request' }}
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace
rust_test:
name: Rust tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
default: true
toolchain: nightly
- name: Run rust tests
run: cargo test
clippy_check:
name: Clippy linter check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: clippy
default: true
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
permissions:
checks: write
contents: read
pull-requests: write

jobs:
contracts:
name: Contracts
uses: ElrondNetwork/elrond-actions/.github/workflows/contracts.yml@v1
with:
rust-toolchain: nightly-2022-10-16
vmtools-version: v1.4.43
extra-build-args: --ignore-eei-checks
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
64 changes: 36 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,47 @@ name: Create release

on:
workflow_dispatch:
inputs:
tag:
required: true
description: Release tag
title:
required: true
description: Release title
image_tag:
type: choice
required: true
description: Image elrondnetwork/build-contract-rust
options:
- v3.2.3

env:
# https://github.com/actions/runner/issues/863 ($HOME is overridden for containers)
ELROND_HOME: /home/elrond
REPO_PATH: /home/elrond/sc-dex-rs
REPO_URL: https://github.com/ElrondNetwork/sc-dex-rs.git
permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
# See: https://docs.github.com/en/actions/using-jobs/running-jobs-in-a-container
container:
image: elrondnetwork/elrond-sdk-erdpy-rust:latest
steps:
# We don't use actions/checkout, since we want to control the location of the repository,
# in order to achieve deterministic builds.
- name: Check out code
run: |
echo "Cloning ref: $GITHUB_REF_NAME"
cd $ELROND_HOME && git clone $REPO_URL --branch=$GITHUB_REF_NAME --depth=1
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.GITHUB_REF_NAME }}
fetch-depth: 0
repository: ${{ env.GITHUB_REPOSITORY }}

- name: Build WASM files
- name: Download build script
run: |
# Setting $HOME is required by erdpy.
export HOME=$ELROND_HOME
cd $REPO_PATH && bash ./build-wasm.sh
wget https://raw.githubusercontent.com/ElrondNetwork/elrond-sdk-images-build-contract-rust/${{ github.event.inputs.image_tag }}/build_with_docker.py
- name: Build contract
run: |
python3 ./build_with_docker.py --no-docker-tty --image=elrondnetwork/build-contract-rust:${{ github.event.inputs.image_tag }} --project=. --output=/home/runner/work/output-from-docker
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: built-contracts
path: |
${{ env.REPO_PATH }}/**/output/*.wasm
${{ env.REPO_PATH }}/**/output/*.abi.json
/home/runner/work/output-from-docker/**/*.wasm
/home/runner/work/output-from-docker/**/*.abi.json
if-no-files-found: error

release:
Expand All @@ -56,14 +63,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "## Checksums (SHA 256):" >> notes.txt
echo "Built using Docker image: **elrondnetwork/build-contract-rust:${{ github.event.inputs.image_tag }}**." >> notes.txt
echo "" >> notes.txt
for i in $(find ./assets -type f); do
echo "## Codehash (blake2b):" >> notes.txt
echo "" >> notes.txt
for i in $(find ./assets -type f -name *.wasm); do
filename=$(basename ${i})
checksum=($(sha256sum ${i}))
checksum=($(b2sum -l 256 ${i}))
echo " - **${filename}**: \`${checksum}\`" >> notes.txt
done
gh release create vNext --draft --title="Release draft from Github Actions" --generate-notes --notes-file=notes.txt
gh release upload vNext $(find ./assets -type f)
gh release create ${{ github.event.inputs.tag }} --target=$GITHUB_SHA --prerelease --title="${{ github.event.inputs.title }}" --generate-notes --notes-file=notes.txt
sleep 10
gh release upload ${{ github.event.inputs.tag }} $(find ./assets -type f)

0 comments on commit 00a5979

Please sign in to comment.