Skip to content
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

[ci] Move CI to GHA #235

Merged
merged 15 commits into from
Sep 25, 2024
166 changes: 166 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: CI

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# common variable is defined in the workflow
# repo env variable doesn't work for PR from forks
env:
CI_IMAGE: "paritytech/ci-unified:bullseye-1.75.0-2024-01-22-v20240222"

jobs:
set-image:
# This workaround sets the container image for each job using 'set-image' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
CI_IMAGE: ${{ steps.set_image.outputs.CI_IMAGE }}
steps:
- id: set_image
run: echo "CI_IMAGE=${{ env.CI_IMAGE }}" >> $GITHUB_OUTPUT

fmt:
name: Cargo fmt
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [set-image]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Cargo fmt
run: cargo +nightly fmt --all -- --check

build-test-linux:
name: Build Linux
runs-on: parity-large
timeout-minutes: 50
needs: [set-image, fmt]
container:
image: ${{ needs.set-image.outputs.CI_IMAGE }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Build and Test Linux
run: |
echo "######## cargo build ########"
cargo build --release
echo "######## cargo test ########"
cargo test --release --all
echo "######## Packing artifacts ########"
mkdir -p ./artifacts/substrate-contracts-node-linux/
cp target/release/substrate-contracts-node ./artifacts/substrate-contracts-node-linux/substrate-contracts-node
ls -la ./artifacts/substrate-contracts-node-linux/
- name: Upload artifacts
uses: actions/[email protected]
with:
name: build-linux
path: ./artifacts
build-macos:
timeout-minutes: 30
runs-on: parity-macos
needs: [fmt]
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Set rust version from env file
run: |
echo $CI_IMAGE
RUST_VERSION=$(echo $CI_IMAGE | sed -E 's/.*ci-unified:([^-]+)-([^-]+).*/\2/')
echo $RUST_VERSION
echo "RUST_VERSION=${RUST_VERSION}" >> $GITHUB_ENV
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@1ccc07ccd54b6048295516a3eb89b192c35057dc # master from 12.09.2024
- name: Install protobuf
run: brew install protobuf
- name: Install rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@1fbea72663f6d4c03efaab13560c8a24cfd2a7cc # v1.9.0
with:
cache: false
toolchain: ${{ env.RUST_VERSION }}
target: wasm32-unknown-unknown, aarch64-apple-darwin, x86_64-apple-darwin
components: cargo, clippy, rust-docs, rust-src, rustfmt, rustc, rust-std
- name: cargo info
run: |
echo "######## rustup show ########"
rustup show
echo "######## cargo --version ########"
cargo --version
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
with:
cache-on-failure: true
cache-all-crates: true
- name: Run cargo build
run: |
echo "######## cargo build aarch64-apple-darwin ########"
cargo build --release --target aarch64-apple-darwin
echo "######## cargo build x86_64-apple-darwin ########"
cargo build --release --target x86_64-apple-darwin
echo "######## Packing artifacts ########"
mkdir -p ./artifacts/substrate-contracts-node-mac/
lipo ./target/x86_64-apple-darwin/release/substrate-contracts-node \
./target/aarch64-apple-darwin/release/substrate-contracts-node \
-create -output ./artifacts/substrate-contracts-node-mac/substrate-contracts-node
ls -la ./artifacts/substrate-contracts-node-mac/
- name: Upload artifacts
uses: actions/[email protected]
with:
name: build-macos
path: ./artifacts
publish:
name: Publish release
runs-on: ubuntu-latest
needs: [build-test-linux, build-macos]
permissions:
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-linux
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: build-macos
- name: Pack artifacts
run: |
tar -czvf ./substrate-contracts-node-linux.tar.gz ./substrate-contracts-node-linux
tar -czvf ./substrate-contracts-node-mac-universal.tar.gz ./substrate-contracts-node-mac
ls -la
- name: Publish release
uses: ghalactic/github-release-from-tag@cebdacac0ccd08933b8e7f278f4123723ad978eb # v5.4.0
if: github.ref_type == 'tag'
with:
prerelease: false
draft: true
assets: |
- path: substrate-contracts-node-linux.tar.gz
- path: substrate-contracts-node-mac-universal.tar.gz
22 changes: 0 additions & 22 deletions .github/workflows/gitspiegel-trigger.yml

This file was deleted.

165 changes: 0 additions & 165 deletions .gitlab-ci.yml

This file was deleted.

18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ We can have two types of releases:
`cargo release 0.XX.0 -v --no-tag --no-push -p contracts-node --execute`
Note: Before uploading, perform a dry run to ensure that it will be successful.
- [ ] Merge the release PR branch.
- [ ] Replace `XX` in this command with your incremented version number and execute it:
`git checkout main && git pull && git tag v0.XX.0 && git push origin v0.XX.0`.
This will push a new tag with the version number to this repository.
- [ ] We have set this repository up in a way that tags à la `vX.X.X` trigger
a CI run that creates a GitHub draft release. You can observe CI runs on
[GitLab](https://gitlab.parity.io/parity/mirrors/substrate-contracts-node/-/pipelines).
- [ ] Set the tag and run the following commands to push the tag. The tag must contain a message, otherwise the github action won't be able to create a release:

```bash
TAG="v0.XX.0"
git checkout main
git pull
git tag -a ${TAG} -m "${TAG}"
git push origin ${TAG}
```


- [ ] After tag is pushed CI creates a GitHub draft release.
This draft release will contain a binary for Linux and Mac and appear
under [Releases](https://github.com/paritytech/substrate-contracts-node/releases).
Add a description in the style of "Synchronized with [`polkadot-v1.8.0`](https://github.com/paritytech/polkadot-sdk/tree/release-polkadot-v1.8.0) branch."
Expand Down