Release 0.2.21 (#935) #188
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
name: post_pr | |
# on push to main, or manually triggered | |
# we do this because any branch can use caches built on main, whereas caches built on other branches are only available to that branch and its children | |
on: | |
push: | |
branches: | |
- 'main' | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install npm | |
run: npm i -g npm@$(cat package.json | jq -r .engines.npm) | |
- run: mkdir -p protocol/cargo-cache | |
- run: mkdir -p protocol/target | |
- run: mkdir -p node_modules | |
- run: mkdir -p ~/.cache/Cypress | |
- run: npm install | |
- run: npm run removePolkadotJSWarnings | |
- name: Rust formatting check | |
run: | | |
cd protocol/dev | |
npm run build | |
npm run cli -- fmt --all --verbose --docker | |
- name: Clippy | |
run: | | |
cd protocol/dev | |
npm run build | |
npm run cli -- clippy --docker -- -- -D warnings | |
- name: Build contracts | |
run: | | |
cd protocol/dev | |
npm run cli -- build --docker --skip-env | |
- name: Test contracts | |
run: | | |
cd protocol/dev | |
RUST_BACKTRACE=1 npm run cli -- test --docker | |
# install cypress so we don't have to do that every time | |
- name: Cypress install | |
run: | | |
npm i --save-dev cypress | |
npx cypress install | |
- run: ls -la ~/.cache/Cypress || true | |
- run: ls -la protocol/cargo-cache || true | |
- run: ls -la protocol/target/ink || true | |
- run: ls -la node_modules || true | |
# remove all but the latest cache (this ensures there's at least one cache available for the next run, just in case this takes place while we're clearing up caches) | |
# this means there will be the previous cache (the latest) and the current cache (the one we're building now) after this workflow finishes | |
# github actions will prefer the latest cache, so the one output from this workflow will take precedence in future jobs | |
- name: Cleanup caches | |
if: always() | |
run: | | |
set +e; gh extension install actions/gh-actions-cache; set -e | |
REPO=${{ github.repository }} | |
echo "Fetching list of cache key" | |
cacheKeys=$(gh actions-cache list --sort created-at --order desc --limit 100 -R $REPO --key project-cache-${{ runner.os }}-${{ runner.arch }}- | cut -f 1 | tail -n +3) | |
echo caches to be removed: | |
echo ${cacheKeys} | |
set +e | |
for cacheKey in $cacheKeys | |
do | |
gh actions-cache delete $cacheKey -R $REPO --confirm | |
done | |
# save cache to main branch. Any branch can use this cache afterwards to speed up their build | |
- name: Save cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: | | |
protocol/cargo-cache | |
protocol/target | |
node_modules | |
~/.cache/Cypress | |
key: project-cache-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }} |