Compare commits

...

3 Commits

Author SHA1 Message Date
xermicus 75a83af4da ci: clippy (#227)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:43:09 +01:00
xermicus 9c330ef8fc llvm-builder: only run expensive tests on linux (#226)
Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
2025-02-21 16:38:44 +01:00
Yuri Volkov 687cec31ef Using released LLVM in revive build (#220) 2025-02-21 16:30:26 +01:00
3 changed files with 405 additions and 348 deletions
+36
View File
@@ -0,0 +1,36 @@
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++;
}
};
+199 -180
View File
@@ -3,7 +3,7 @@ run-name: Release ${{ github.ref_name }}
on: on:
push: push:
branches: branches:
- 'main' - "main"
concurrency: concurrency:
group: ${{ github.ref }}-${{ github.workflow }} group: ${{ github.ref }}-${{ github.workflow }}
@@ -12,12 +12,9 @@ concurrency:
env: env:
#rust-musl-cross:x86_64-musl #rust-musl-cross:x86_64-musl
RUST_MUSL_CROSS_IMAGE: messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561 RUST_MUSL_CROSS_IMAGE: messense/rust-musl-cross@sha256:68b86bc7cb2867259e6b233415a665ff4469c28b57763e78c3bfea1c68091561
RUST_LOG: trace
jobs: jobs:
#
#
#
tag: tag:
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
permissions: permissions:
@@ -25,11 +22,12 @@ jobs:
outputs: outputs:
TAG: ${{ steps.versions.outputs.TAG }} TAG: ${{ steps.versions.outputs.TAG }}
PKG_VER: ${{ steps.versions.outputs.PKG_VER }} PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
RELEASE_NOTES: ${{ steps.versions.outputs.RELEASE_NOTES }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-tags: 'true' fetch-tags: "true"
fetch-depth: 0 fetch-depth: 0
- name: Versions - name: Versions
@@ -41,7 +39,7 @@ jobs:
echo "Package version $PKG_VER" echo "Package version $PKG_VER"
# #
echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT echo "PKG_VER=$PKG_VER" >> $GITHUB_OUTPUT
if [ $CURRENT_TAG == $PKG_VER ]; if [[ $CURRENT_TAG == $PKG_VER ]];
then then
echo "Tag is up to date. Nothing to do."; echo "Tag is up to date. Nothing to do.";
export TAG=old; export TAG=old;
@@ -51,28 +49,56 @@ jobs:
fi fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT 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')"
#
build-linux-all: echo "Release notes:"
echo "$RELEASE_NOTES"
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_OUTPUT
echo "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
build-macos:
strategy:
matrix:
os: [macos-14, macos-13]
include:
- os: macos-13
arch: x64
- os: macos-14
arch: arm64
if: ${{ needs.tag.outputs.TAG == 'new' }} if: ${{ needs.tag.outputs.TAG == 'new' }}
runs-on: parity-large runs-on: ${{ matrix.os }}
name: "build-macos-${{ matrix.arch }}"
needs: [tag] needs: [tag]
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: install linux deps - name: Get latest macos ${{ matrix.arch }} LLVM release artifact
run: | id: get-llvm-artifact
sudo apt-get update && sudo apt-get install -y cmake ninja-build \ uses: actions/github-script@v7
curl git libssl-dev pkg-config clang lld musl with:
result-encoding: string
- name: Install Rust stable toolchain script: |
uses: actions-rs/toolchain@v1 const getReleaseArtifact = require("./.github/workflows/get-release-artifact.js");
return await getReleaseArtifact({
octokit: github,
context,
releasePrefix: "llvm-",
artifactSuffix: "-macos-${{ matrix.arch }}"
});
- uses: actions-rust-lang/setup-rust-toolchain@v1
with: with:
profile: minimal
toolchain: stable toolchain: stable
components: rust-src components: rust-src
target: wasm32-unknown-emscripten target: wasm32-unknown-emscripten
rustflags: ""
- name: install macos deps
run: |
brew install ninja
- name: versions - name: versions
run: | run: |
@@ -83,57 +109,104 @@ jobs:
echo "ninja:" && ninja --version echo "ninja:" && ninja --version
echo "clang:" && clang --version echo "clang:" && clang --version
- name: build revive-llvm - name: download llvm
run: make install-llvm-builder
# musl LLVM
- name: llvm-musl-cache restore
id: llvm-musl-cache
uses: actions/cache/restore@v4
with:
path: target-llvm/musl/target-final
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }}
- name: Build musl LLVM
if: steps.llvm-musl-cache.outputs.cache-hit != 'true'
run: | run: |
revive-llvm --target-env musl clone curl -L -o llvm.tar.gz "${{ steps.get-llvm-artifact.outputs.result }}"
revive-llvm --target-env musl build --llvm-projects lld --llvm-projects clang tar -xvf llvm.tar.gz
- name: llvm-musl-cache save - name: build revive
if: steps.llvm-musl-cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: target-llvm/musl/target-final
key: llvm-linux-musl-${{ hashFiles('crates/solidity/**') }}
# emscripten LLVM
- name: llvm-emscripten-cache restore
id: llvm-emscripten-cache
uses: actions/cache/restore@v4
with:
path: |
target-llvm/emscripten/target-final
emsdk
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }}
- name: Build emscripten LLVM
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true'
run: | run: |
revive-llvm --target-env emscripten clone export LLVM_SYS_181_PREFIX=$PWD/target-llvm/gnu/target-final
source emsdk/emsdk_env.sh make install-bin
revive-llvm --target-env emscripten build --llvm-projects lld cp ./target/release/resolc ./target/release/resolc-${{ matrix.arch }}
- name: llvm-emscripten-cache save - name: check revive
if: steps.llvm-emscripten-cache.outputs.cache-hit != 'true' run: |
uses: actions/cache/save@v4 mkdir solc
curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-macos
chmod +x solc/solc
PATH=$PWD/solc:$PATH
result=$(./target/release/resolc-${{ matrix.arch }} --bin crates/integration/contracts/flipper.sol)
echo $result
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
- uses: actions/upload-artifact@v4
with: with:
name: "revive-macos-${{ matrix.arch }}"
path: | path: |
target-llvm/emscripten/target-final ./target/release/resolc-${{ matrix.arch }}
emsdk retention-days: 1
key: llvm-linux-emscripten-${{ hashFiles('crates/solidity/**') }}
macos-universal-binary:
runs-on: macos-14
needs: [build-macos]
steps:
- uses: actions/download-artifact@v4
with:
pattern: revive-macos-*
path: revive-macos
- name: run lipo
run: |
lipo revive-macos/revive-macos-arm64/resolc-arm64 revive-macos/revive-macos-x64/resolc-x64 -create -output resolc-macos
- name: compress macos artifact
run: |
tar -czf resolc-macos.tar.gz ./resolc-macos
- uses: actions/upload-artifact@v4
with:
name: revive-macos
path: |
resolc-macos.tar.gz
retention-days: 1
build-linux-all:
if: ${{ needs.tag.outputs.TAG == 'new' }}
runs-on: parity-large
needs: [tag]
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 \
curl git libssl-dev pkg-config clang lld musl
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rust-src
target: wasm32-unknown-emscripten
rustflags: ""
- name: versions
run: |
rustup show
cargo --version
cmake --version
echo "bash:" && bash --version
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
# Build revive # Build revive
@@ -145,7 +218,7 @@ jobs:
apt update && apt upgrade -y && apt install -y pkg-config apt update && apt upgrade -y && apt install -y pkg-config
export LLVM_SYS_181_PREFIX=/opt/revive/target-llvm/musl/target-final export LLVM_SYS_181_PREFIX=/opt/revive/target-llvm/musl/target-final
make install-bin make install-bin
cp /root/.cargo/bin/resolc /opt/revive/resolc-out/resolc cp /root/.cargo/bin/resolc /opt/revive/resolc-out/resolc-static-linux
" "
- name: check musl - name: check musl
@@ -154,17 +227,49 @@ jobs:
curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-static-linux curl -sSLo solc/solc https://github.com/ethereum/solidity/releases/download/v0.8.28/solc-static-linux
chmod +x solc/solc chmod +x solc/solc
PATH=$PWD/solc:$PATH PATH=$PWD/solc:$PATH
result=$(./resolc-out/resolc --bin crates/integration/contracts/flipper.sol) result=$(./resolc-out/resolc-static-linux --bin crates/integration/contracts/flipper.sol)
echo $result echo $result
if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi if [[ $result == *'0x50564d'* ]]; then exit 0; else exit 1; fi
- name: compress musl artifact
run: |
tar --strip-components 1 -czf resolc-static-linux.tar.gz ./resolc-out/resolc-static-linux
- uses: actions/upload-artifact@v4
with:
name: revive-linux
path: |
./resolc-static-linux.tar.gz
retention-days: 1
- name: Set Up Node.js - name: Set Up Node.js
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: "20" node-version: "20"
- name: Get latest emscripten LLVM release artifact
id: get-llvm-emscripten-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: "-wasm32-unknown-emscripten"
})
- name: download llvm
run: |
curl -L -o llvm.tar.gz "${{ steps.get-llvm-emscripten-artifact.outputs.result }}"
tar -xvf llvm.tar.gz
- name: build wasm - name: build wasm
run: | run: |
make install-llvm-builder
revive-llvm --target-env emscripten clone
export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final export LLVM_SYS_181_PREFIX=$PWD/target-llvm/musl/target-final
export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final export REVIVE_LLVM_TARGET_PREFIX=$PWD/target-llvm/emscripten/target-final
source emsdk/emsdk_env.sh source emsdk/emsdk_env.sh
@@ -208,140 +313,54 @@ jobs:
if(!bytecode.startsWith('50564d')) { process.exit(1); } if(!bytecode.startsWith('50564d')) { process.exit(1); }
" "
- name: compress wasm artifact
run: |
tar --strip-components 3 -czf resolc-wasm.tar.gz \
./target/wasm32-unknown-emscripten/release/resolc.js \
./target/wasm32-unknown-emscripten/release/resolc.wasm \
./target/wasm32-unknown-emscripten/release/resolc_web.js
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
name: revive-wasm name: revive-wasm
path: | path: |
./target/wasm32-unknown-emscripten/release/resolc.js resolc-wasm.tar.gz
./target/wasm32-unknown-emscripten/release/resolc.wasm
./target/wasm32-unknown-emscripten/release/resolc_web.js
retention-days: 1 retention-days: 1
- uses: actions/upload-artifact@v4
with:
name: revive-linux
path: |
./resolc-out/resolc
retention-days: 1
#
#
#
create-release: create-release:
needs: [tag, build-linux-all] needs: [tag, build-linux-all, macos-universal-binary]
runs-on: ubuntu-24.04 runs-on: ubuntu-24.04
permissions: permissions:
contents: write contents: write
outputs: outputs:
upload_url: ${{ steps.create_release.outputs.result }} upload_url: ${{ steps.create_release.outputs.result }}
steps: steps:
- uses: actions/checkout@v4 - name: Download revive-wasm
- name: Create/update tag
id: tag
uses: actions/github-script@v7
with:
result-encoding: string
script: |
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ needs.tag.outputs.PKG_VER }}',
sha: context.sha
})
- name: get relese notes
id: get-notes
run: |
{
echo 'releaseNotes<<EOF'
sed '/^## ${{ needs.tag.outputs.PKG_VER }}/,/^## v/!d' CHANGELOG.md | sed -e '1d' -e '$d'
echo EOF
} >> "$GITHUB_OUTPUT"
- name: Create release
id: create_release
env:
releaseNotes: ${{ steps.get-notes.outputs.releaseNotes }}
version: ${{ needs.tag.outputs.PKG_VER }}
uses: actions/github-script@v7
with:
result-encoding: string
script: |
let response = await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: process.env.version,
name: process.env.version,
body: process.env.releaseNotes,
draft: true,
prerelease: true
});
console.log(response);
return response.data.upload_url;
- name: Log
run: |
echo "tag result: ${{ needs.tag.outputs.TAG }}"
echo "pkg version: ${{ needs.tag.outputs.PKG_VER }}"
#
#
#
upload-assets:
runs-on: ubuntu-24.04
needs: [create-release]
steps:
- name: Download Artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: revive-wasm name: revive-wasm
path: resolc/ path: resolc-wasm/
- name: Download Artifact - name: Download revive-linux
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: revive-linux name: revive-linux
path: resolc/ path: resolc-linux/
- name: upload resolc - name: Download revive-macos
uses: actions/upload-release-asset@v1 uses: actions/download-artifact@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ needs.create-release.outputs.upload_url }} name: revive-macos
asset_path: ./resolc/resolc path: resolc-macos/
asset_name: resolc-static-linux
asset_content_type: application/octet-stream
- name: upload resolc.js - name: create-release
uses: actions/upload-release-asset@v1 uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
upload_url: ${{ needs.create-release.outputs.upload_url }} body: ${{ needs.tag.outputs.RELEASE_NOTES }}
asset_path: ./resolc/resolc.js tag_name: ${{ needs.tag.outputs.PKG_VER }}
asset_name: resolc.js name: ${{ needs.tag.outputs.PKG_VER }}
asset_content_type: application/octet-stream draft: true
files: |
- name: upload resolc.wasm ./resolc-linux/resolc-static-linux.tar.gz
uses: actions/upload-release-asset@v1 ./resolc-macos/resolc-macos.tar.gz
env: ./resolc-wasm/resolc-wasm.tar.gz
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./resolc/resolc.wasm
asset_name: resolc.wasm
asset_content_type: application/octet-stream
- name: upload resolc_web.js
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: ./resolc/resolc_web.js
asset_name: resolc_web.js
asset_content_type: application/octet-stream
+3 -1
View File
@@ -83,6 +83,7 @@ fn clone_build_and_clean_musl() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully cloned and built in debug mode /// This test verifies that the LLVM repository can be successfully cloned and built in debug mode
/// with tests and coverage enabled. /// with tests and coverage enabled.
#[test] #[test]
#[cfg(target_os = "linux")]
fn debug_build_with_tests_coverage() -> anyhow::Result<()> { fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
@@ -107,6 +108,7 @@ fn debug_build_with_tests_coverage() -> anyhow::Result<()> {
/// This test verifies that the LLVM repository can be successfully built with address sanitizer. /// This test verifies that the LLVM repository can be successfully built with address sanitizer.
#[test] #[test]
#[cfg(target_os = "linux")]
fn build_with_sanitizers() -> anyhow::Result<()> { fn build_with_sanitizers() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
@@ -129,7 +131,7 @@ fn build_with_sanitizers() -> anyhow::Result<()> {
/// Tests the clone, build, and clean process of the LLVM repository for the emscripten target. /// Tests the clone, build, and clean process of the LLVM repository for the emscripten target.
#[test] #[test]
#[cfg(any(target_os = "linux", target_os = "macos"))] #[cfg(target_os = "linux")]
fn clone_build_and_clean_emscripten() -> anyhow::Result<()> { fn clone_build_and_clean_emscripten() -> anyhow::Result<()> {
let test_dir = common::TestDir::with_lockfile(None)?; let test_dir = common::TestDir::with_lockfile(None)?;
let command = Command::cargo_bin(common::REVIVE_LLVM)?; let command = Command::cargo_bin(common::REVIVE_LLVM)?;