CI improvements (#230)

- llvm artifacts search, download and extract now in `get-llvm` action 
- `get-emsdk` action - clone, install, activate emsdk, so we don't need
to build `revive-builder` for this
- switch workflows to new actions
- `concurrency` for remaining workflows (cancel run if new run is
triggered)
- `target_commitish` for main release, fixes release commit 
- Run release workflow in PR without creating a release if PR is labeled
with `release-test`

---------

Co-authored-by: cornholio <0@mcornholio.ru>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: xermicus <cyrill@parity.io>
Co-authored-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
Evgeny Snitko
2025-02-25 17:33:59 +04:00
committed by GitHub
parent f1bce4fe3f
commit 7ffe64ed7c
8 changed files with 169 additions and 138 deletions
+20
View File
@@ -0,0 +1,20 @@
name: "get emsdk"
inputs:
version:
description: ""
required: false
default: "3.1.64"
runs:
using: "composite"
steps:
- name: install emsdk
shell: bash
run: |
git clone https://github.com/emscripten-core/emsdk.git ./emsdk/
cd emsdk
git checkout tags/${{ inputs.version }}
./emsdk install ${{ inputs.version }}
./emsdk activate ${{ inputs.version }}
+91
View File
@@ -0,0 +1,91 @@
# example:
#
# - name: get llvm
# uses: ./.github/actions/get-llvm
# with:
# releasePrefix: llvm-
# artifactArch: macos-arm64
# dir: target-llvm/macos
name: "get llvm"
inputs:
artifactArch:
required: true
releasePrefix:
description: "LLVM release tag prefix to search"
required: false
default: "llvm-"
dir:
description: "Archive extract path (`tar -C`)"
required: false
default: "./"
stripComponents:
description: "Strip UMBER leading components from file names on extraction (`tar --strip-components`)"
required: false
default: 0
runs:
using: "composite"
steps:
- name: find asset
id: find
uses: actions/github-script@v7
env:
releasePrefix: ${{ inputs.releasePrefix }}
artifactArch: ${{ inputs.artifactArch }}
with:
result-encoding: string
script: |
let page = 1;
let releases = [];
let releasePrefix = process.env.releasePrefix
let artifactArch = process.env.artifactArch
do {
const res = await github.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 50,
page,
});
releases = res.data
releases.sort((a, b) => {
return (a.published_at < b.published_at) ? 1 : ((a.published_at > b.published_at) ? -1 : 0);
});
let llvmLatestRelease = releases.find(release => {
return release.tag_name.startsWith(releasePrefix);
});
if (llvmLatestRelease){
let asset = llvmLatestRelease.assets.find(asset =>{
return asset.name.includes(artifactArch);
});
if (!asset){
core.setFailed(`Artifact for '${artifactArch}' not found in release ${llvmLatestRelease.tag_name} (${llvmLatestRelease.html_url})`);
process.exit();
}
return asset.browser_download_url;
}
page++;
} while(releases.length > 0);
core.setFailed(`No LLVM releases with '${releasePrefix}' atifacts found! Please release LLVM before running this workflow.`);
process.exit();
- name: download
shell: bash
run: |
mkdir -p ${{ inputs.dir }}
curl -sSLo llvm.tar.gz ${{ steps.find.outputs.result }}
ls -al
- name: unpack
shell: bash
run: |
tar -xf llvm.tar.gz -C ${{ inputs.dir }} --strip-components=${{ inputs.stripComponents }}
rm llvm.tar.gz
ls -al ${{ inputs.dir }}
+18 -37
View File
@@ -6,62 +6,48 @@ on:
branches: ["main"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
REVIVE_WASM_INSTALL_DIR: ${{ github.workspace }}/target/wasm32-unknown-emscripten/release
jobs:
build-revive-wasm:
runs-on: parity-large
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- name: Cache LLVM build
id: cache-llvm
uses: actions/cache@v3
with:
path: |
target-llvm/emscripten/target-final
target-llvm/gnu/target-final
# Use a unique key based on LLVM version or configuration files to avoid cache invalidation
key: llvm-build-${{ runner.os }}-${{ hashFiles('LLVM.lock', 'Cargo.toml', 'Cargo.lock', 'crates/llvm-builder/**', '.github/workflows/build-revive-wasm.yml') }}
- name: Install system dependencies
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build curl git libssl-dev pkg-config clang lld
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
profile: minimal
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: Install LLVM build dependencies
run: |
make install-llvm-builder
revive-llvm --target-env emscripten clone
- name: get llvm gnu
uses: ./.github/actions/get-llvm
with:
artifactArch: x86_64-linux-gnu
- name: get llvm emscripten
uses: ./.github/actions/get-llvm
with:
artifactArch: emscripten
- name: install emsdk
uses: ./.github/actions/get-emsdk
- name: Setup revive environment variables
run: |
echo "LLVM_SYS_181_PREFIX=$(pwd)/target-llvm/gnu/target-final" >> $GITHUB_ENV
echo "REVIVE_LLVM_TARGET_PREFIX=$(pwd)/target-llvm/emscripten/target-final" >> $GITHUB_ENV
- name: Build host LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
revive-llvm build --llvm-projects lld --llvm-projects clang
- name: Build target LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
source emsdk/emsdk_env.sh
revive-llvm --target-env emscripten build --llvm-projects lld
- run: |
rustup show
cargo --version
@@ -70,11 +56,6 @@ jobs:
cmake --version
bash --version
- name: Use Cached LLVM
if: steps.cache-llvm.outputs.cache-hit == 'true'
run: |
echo "Using cached LLVM"
- name: Build revive
run: |
source emsdk/emsdk_env.sh
-36
View File
@@ -1,36 +0,0 @@
module.exports = async ({
octokit,
context,
releasePrefix,
artifactSuffix,
}) => {
let page = 1;
while (true) {
const res = await octokit.rest.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo,
per_page: 100,
page,
});
if (res.data.length === 0) {
throw new Error(
`No LLVM releases with '${artifactSuffix}' atifacts found! Please release LLVM before running this workflow.`,
);
}
for (let release of res.data) {
if (release.tag_name.startsWith(releasePrefix)) {
for (let asset of release.assets) {
if (asset.name.includes(artifactSuffix)) {
return asset.browser_download_url;
}
}
console.warn(
`LLVM release ${release.tag_name} doesn't have a '${artifactSuffix}' artifact; searching for older releases...`,
);
}
}
page++;
}
};
+4
View File
@@ -8,6 +8,10 @@ on:
required: true
description: llvm version in "x.x.x" format, e.g. "18.1.8"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
+27 -60
View File
@@ -4,9 +4,11 @@ on:
push:
branches:
- "main"
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
@@ -16,6 +18,7 @@ env:
jobs:
tag:
if: github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'release-test')
runs-on: ubuntu-24.04
permissions:
contents: write
@@ -48,13 +51,13 @@ jobs:
export TAG=new;
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT
# Generating release notes early, in order to avoid checkout at the last step
export RELEASE_NOTES="$(sed '/^## '${PKG_VER}'/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d')"
echo "Release notes:"
echo "$RELEASE_NOTES"
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
@@ -70,24 +73,17 @@ jobs:
arch: arm64
if: ${{ needs.tag.outputs.TAG == 'new' }}
runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
name: build-macos
needs: [tag]
steps:
- uses: actions/checkout@v4
- name: Get latest macos ${{ matrix.arch }} LLVM release artifact
id: get-llvm-artifact
uses: actions/github-script@v7
- name: get llvm
uses: ./.github/actions/get-llvm
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js");
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-macos-${{ matrix.arch }}"
});
releasePrefix: llvm-
artifactArch: macos-${{ matrix.arch }}
dir: ./
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
@@ -109,11 +105,6 @@ jobs:
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: build revive
run: |
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/gnu/target-final
@@ -168,20 +159,6 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Get latest linux LLVM release artifact
id: get-llvm-musl-artifact
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-x86_64-linux-musl"
})
- name: install linux deps
run: |
sudo apt-get update && sudo apt-get install -y cmake ninja-build \
@@ -203,10 +180,12 @@ jobs:
echo "ninja:" && ninja --version
echo "clang:" && clang --version
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-musl-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: get llvm musl
uses: ./.github/actions/get-llvm
with:
releasePrefix: llvm-
artifactArch: x86_64-linux-musl
dir: ./
# Build revive
@@ -247,29 +226,16 @@ jobs:
with:
node-version: "20"
- name: Get latest emscripten LLVM release artifact
id: get-llvm-emscripten-artifact
uses: actions/github-script@v7
- name: get llvm emscripten
uses: ./.github/actions/get-llvm
with:
result-encoding: string
script: |
const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js")
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-wasm32-unknown-emscripten"
})
artifactArch: emscripten
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-emscripten-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: install emsdk
uses: ./.github/actions/get-emsdk
- name: build wasm
run: |
make install-llvm-builder
revive-llvm --target-env emscripten clone
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final
export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final
source emsdk/emsdk_env.sh
@@ -328,12 +294,11 @@ jobs:
retention-days: 1
create-release:
if: github.event_name != 'pull_request'
needs: [tag, build-linux-all, macos-universal-binary]
runs-on: ubuntu-24.04
permissions:
contents: write
outputs:
upload_url: ${{ steps.create_release.outputs.result }}
steps:
- name: Download revive-wasm
uses: actions/download-artifact@v4
@@ -360,7 +325,9 @@ jobs:
tag_name: ${{ needs.tag.outputs.PKG_VER }}
name: ${{ needs.tag.outputs.PKG_VER }}
draft: true
target_commitish: ${{ github.sha }}
files: |
./resolc-linux/resolc-static-linux.tar.gz
./resolc-macos/resolc-macos.tar.gz
./resolc-wasm/resolc-wasm.tar.gz
+4
View File
@@ -6,6 +6,10 @@ on:
pull_request:
branches: ["main"]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
+5 -5
View File
@@ -14,7 +14,7 @@ Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
### Added
### Changed
### Changed
### Fixed
- A bug causing incorrect loads from the emulated EVM linear memory.
@@ -30,7 +30,7 @@ Supported `polkadot-sdk` rev: `274a781e8ca1a9432c7ec87593bd93214abbff50`
- Support for the `coinbase` opcode.
- The resolc web JS version.
### Changed
### Changed
- Missing the `--overwrite` flag emits an error instead of a warning.
- The `resolc` executable prints the help by default.
- Removed support for legacy EVM assembly (EVMLA) translation.
@@ -52,7 +52,7 @@ This is a development pre-release.
### Added
### Changed
### Changed
- Syscalls with more than 6 arguments now pack them into registers.
### Fixed
@@ -92,9 +92,9 @@ This is a development pre-release.
- Calls forward maximum weight limits instead of 0, anticipating a change in polkadot-sdk where weight limits of 0 no longer interprets as uncapped limit.
### Fixed
- A linker bug which was preventing certain contracts from linking with the PVM linker.
- A linker bug which was preventing certain contracts from linking with the PVM linker.
- JS: Fix encoding conversion from JS string (UTF-16) to UTF-8.
- The git commit hash slug is always displayed in the version string.
- The git commit hash slug is always displayed in the version string.
## v0.1.0-dev.6