Skip to content

Commit

Permalink
# This is a combination of 7 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

rebase

# This is the commit message #2:

rebase

# This is the commit message #3:

add origin

# This is the commit message #4:

Delete build-artifacts.yml
# This is the commit message #5:

rebase

# This is the commit message #6:

fixes #535 (#553)

* fixes #535

* don't skip integration tests

* remove ref: main

* get github ref from action

* try base_ref

* try GITHUB_SHA

* GITHUB_REF_NAME

* back to GITHUB_SHA

* checkout pull request commit

* renamee to release-pipeline

* back to

Co-authored-by: Seun Lanlege <seunlanlege@gmail.com>
# This is the commit message #7:

fetch depth
  • Loading branch information
haroldsphinx committed Jan 27, 2022
1 parent 3a55b92 commit 06dd757
Show file tree
Hide file tree
Showing 14 changed files with 367 additions and 132 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main

jobs:
benchmark:
benchmark:
name: Benchmark
runs-on:
- self-hosted
Expand All @@ -24,18 +24,21 @@ jobs:
- uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Check for runtime changes
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}

id: check_runtime
if: github.event.label.name == 'needs-benchmarks'
run: .maintain/check_runtime.sh

- name: Benchmark Test
env:
BASE_BRANCH: ${{ github.event.pull_request.base.ref }}

if: env.RUNTIME_CHECK == 1
id: run_benchmarks
run: .maintain/run_benchmarks.sh
4 changes: 2 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
# TODO: https://github.com/ComposableFi/composable/issues/535
/home/runner/.cargo/bin/cargo install -f cargo-llvm-cov
/home/runner/.cargo/bin/rustup component add llvm-tools-preview --toolchain=nightly-2021-11-08
SKIP_WASM_BUILD=1 /home/runner/.cargo/bin/cargo +nightly-2021-11-08 llvm-cov --workspace --locked --release --verbose --features=runtime-benchmarks --exclude=integration-tests --lcov --output-path lcov.info
SKIP_WASM_BUILD=1 /home/runner/.cargo/bin/cargo +nightly-2021-11-08 llvm-cov --workspace --locked --release --verbose --features=runtime-benchmarks --lcov --output-path lcov.info
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
- uses: actions/checkout@v2
- name: Run Test
run: |
SKIP_WASM_BUILD=1 cargo test --workspace --locked --release --verbose --features=runtime-benchmarks --exclude=integration-tests
SKIP_WASM_BUILD=1 cargo test --workspace --locked --release --verbose --features=runtime-benchmarks
linters:
name: Linters
Expand Down
144 changes: 71 additions & 73 deletions .github/workflows/devnet-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,76 +13,74 @@ jobs:
group: deploy-devnet
cancel-in-progress: false
steps:
- name: Clean up
continue-on-error: true
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
docker system prune --force --all --volumes
- uses: actions/checkout@v2

- uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
export_default_credentials: true

- uses: actions/setup-python@v2

- uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v10
with:
name: composable-community
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: composable-community

- name: Set env
run: |
echo "RELEASE_VERSION=$GITHUB_SHA" >> $GITHUB_ENV
- name: Push artifact
run: |
/home/runner/.cargo/bin/cargo build --release
tar -czvf composable-picasso-${{ env.RELEASE_VERSION }}.tar.gz target/release/composable
gsutil mv *.tar.gz gs://composable-binaries/community-releases/picasso/
- name: Load state
run: |
cd nix
echo $(cat devnet.json | jq --arg version "${{ env.RELEASE_VERSION }}" '.composable.version = $version' | jq --arg hash "$(nix-prefetch-url https://storage.googleapis.com/composable-binaries/community-releases/picasso/composable-picasso-${{ env.RELEASE_VERSION }}.tar.gz)" '.composable.hash = $hash') > devnet.json
jq --null-input --arg client_email "$GCP_DEVNET_SERVICE_ACCOUNT" --arg project_id "$GCP_PROJECT_ID" --arg key "\"$GCP_DEVNET_SERVICE_ACCOUNT_KEY\"" '{ "project_id": $project_id, "private_key": ($key | fromjson), "client_email": $client_email }' > ops.json
if gsutil -q stat $NIXOPS_STATE_URL/$NIXOPS_STATE;
then
gsutil cp $NIXOPS_STATE_URL/$NIXOPS_STATE $NIXOPS_STATE
else
nix develop .#deploy --impure --command nixops create -d devnet-gce
fi
env:
NIXOPS_STATE_URL: "gs://composable-state"
NIXOPS_STATE: "deployment.nixops"
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_DEVNET_SERVICE_ACCOUNT: ${{ secrets.GCP_DEVNET_SERVICE_ACCOUNT }}
GCP_DEVNET_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_DEVNET_SERVICE_ACCOUNT_KEY }}

- name: Deploy
run: |
cd nix
nix develop .#deploy --impure --command nixops deploy --check --confirm -d devnet-gce
env:
NIXOPS_STATE: "deployment.nixops"

- name: Store state
if: always()
run: |
cd nix
gsutil cp $NIXOPS_STATE $NIXOPS_STATE_URL/
env:
NIXOPS_STATE: "deployment.nixops"
NIXOPS_STATE_URL: "gs://composable-state"

- name: Clean up
continue-on-error: true
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
docker system prune --force --all --volumes
- uses: actions/checkout@v2

- uses: google-github-actions/setup-gcloud@master
with:
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
export_default_credentials: true

- uses: actions/setup-python@v2

- uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v10
with:
name: composable-community
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
extraPullNames: composable-community

- name: Set env
run: |
echo "RELEASE_VERSION=$GITHUB_REF_NAME" >> $GITHUB_ENV
- name: Push artifact
run: |
/home/runner/.cargo/bin/cargo build --release
tar -czvf composable-picasso-${{ env.RELEASE_VERSION }}.tar.gz target/release/composable
gsutil mv *.tar.gz gs://composable-binaries/community-releases/picasso/
- name: Load state
run: |
cd nix
echo $(cat devnet.json | jq --arg version "${{ env.RELEASE_VERSION }}" '.composable.version = $version' | jq --arg hash "$(nix-prefetch-url https://storage.googleapis.com/composable-binaries/community-releases/picasso/composable-picasso-${{ env.RELEASE_VERSION }}.tar.gz)" '.composable.hash = $hash') > devnet.json
jq --null-input --arg client_email "$GCP_DEVNET_SERVICE_ACCOUNT" --arg project_id "$GCP_PROJECT_ID" --arg key "\"$GCP_DEVNET_SERVICE_ACCOUNT_KEY\"" '{ "project_id": $project_id, "private_key": ($key | fromjson), "client_email": $client_email }' > ops.json
if gsutil -q stat $NIXOPS_STATE_URL/$NIXOPS_STATE;
then
gsutil cp $NIXOPS_STATE_URL/$NIXOPS_STATE $NIXOPS_STATE
else
nix develop .#deploy --impure --command nixops create -d devnet-gce
fi
env:
NIXOPS_STATE_URL: "gs://composable-state"
NIXOPS_STATE: "deployment.nixops"
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GCP_DEVNET_SERVICE_ACCOUNT: ${{ secrets.GCP_DEVNET_SERVICE_ACCOUNT }}
GCP_DEVNET_SERVICE_ACCOUNT_KEY: ${{ secrets.GCP_DEVNET_SERVICE_ACCOUNT_KEY }}

- name: Deploy
run: |
cd nix
nix develop .#deploy --impure --command nixops deploy --check --confirm -d devnet-gce
env:
NIXOPS_STATE: "deployment.nixops"

- name: Store state
if: always()
run: |
cd nix
gsutil cp $NIXOPS_STATE $NIXOPS_STATE_URL/
env:
NIXOPS_STATE: "deployment.nixops"
NIXOPS_STATE_URL: "gs://composable-state"
106 changes: 106 additions & 0 deletions .github/workflows/release-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Release Pipeline
on:
push:
branches:
- releases
jobs:
build-and-publish:
runs-on:
- self-hosted
- linux
- x64
- sre
strategy:
fail-fast: true
steps:
- name: Clean up
continue-on-error: true
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
docker system prune --force --all --volumes
- uses: actions/checkout@v2
with:
fetch-depth: 0

- uses: actions-rs/toolchain@v1
with:
toolchain: stable

- name: Install srtool
run: |
cargo install --git https://github.com/chevdor/srtool-cli
cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.16.1
- name: Runtime wasm builds
id: runtime_release
env:

run: |
.maintain/runtime_release.sh
- uses: release-drafter/release-drafter@v5
id: release_drafter

- name: Set Permission
continue-on-error: true
run: |
sudo su runner
- uses: actions/setup-node@v2
with:
node-version: "16"

- name: Add runtime metadata to release body
run: |
cd scripts/github && npm install
printf "\n%s" "${{ steps.release_drafter.outputs.body }}" >> $GITHUB_WORKSPACE/release.md
npm run update-release-body -- --id=${{ steps.release_drafter.outputs.id }} --repo=composableFi/composable --body="$GITHUB_WORKSPACE/release.md"
cd $GITHUB_WORKSPACE
- name: Upload Dali wasm
id: upload-dali-wasm
if: env.dali_wasm == 1
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: ./runtime/dali/target/srtool/release/wbuild/dali-runtime/dali_runtime.compact.wasm
asset_name: dali_runtime.compact.wasm
asset_content_type: application/octet-stream

- name: Upload Picasso wasm
id: upload-picasso-wasm
if: env.picasso_wasm == 1
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: ./runtime/picasso/target/srtool/release/wbuild/picasso-runtime/picasso_runtime.compact.wasm
asset_name: picasso_runtime.compact.wasm
asset_content_type: application/octet-stream

- name: Upload Composable wasm
id: upload-composable-wasm
if: env.composable_wasm == 1
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: ./runtime/composable/target/srtool/release/wbuild/composable-runtime/composable_runtime.compact.wasm
asset_name: composable_runtime.compact.wasm
asset_content_type: application/octet-stream

- name: 🔨 Build Composable Binary
env:

run: |
.maintain/client_release.sh
- name: Upload Composable Node Binaries
id: upload-composable-binary
if: env.client_release == 1
uses: actions/upload-release-asset@v1

with:
upload_url: ${{ steps.release_drafter.outputs.upload_url }}
asset_path: ./target/release/composable
asset_name: composable
asset_content_type: application/octet-stream
13 changes: 11 additions & 2 deletions .github/workflows/simnode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main
jobs:
simnode:
runs-on:
runs-on:
- self-hosted
- linux
- x64
Expand All @@ -18,10 +18,19 @@ jobs:
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
docker system prune --force --all --volumes
- uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{ steps.branch-name.outputs.current_branch }}

- name: Reset main to get latest commit
shell: bash
run: |
echo "Triggered by commit $(git log -1 --format='%H')"
git pull --no-commit
git reset --hard origin/main
echo "Jumped to commit $(git log -1 --format='%H')"
- name: Get branch name
id: branch-name
Expand Down
15 changes: 7 additions & 8 deletions .maintain/check_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# "auto-fail" the PR if there isn't a change in the runtime/src/lib.rs file
# that alters the version.

#set -e # fail on any error
set -e # fail on any error

#shellcheck source=../common/lib.sh
. "$(dirname "${0}")/./common/lib.sh"
Expand All @@ -14,26 +14,25 @@
VERSIONS_FILES=(
"runtime/picasso/src/lib.rs,picasso,picasso"
"runtime/dali/src/lib.rs,dali-chachacha,dali"
"runtime/composable/src/lib.rs,composable,composable"
"runtime/composable/src/lib.rs,composable,composable"
)

echo "make sure the main branch and release tag are available in shallow clones"
git fetch --depth="${GIT_DEPTH:-100}" origin "${BASE_BRANCH}"
echo "make sure the main branch and release tag are available in shallow clones"
git fetch --depth="${GIT_DEPTH:-100}" origin "${BASE_BRANCH}"

simnode_check() {
VERSIONS_FILE="$1"
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$2" && check_runtime "$VERSIONS_FILE" "$2"
then
if has_runtime_changes "${BASE_BRANCH}" "${GITHUB_REF_NAME}" "$2" && check_runtime "$VERSIONS_FILE" "$2"; then
echo "Wasm sources have changed for $3"
echo "RUNTIME_CHECK=1" >> $GITHUB_ENV
echo "RUNTIME_CHECK=1" >>$GITHUB_ENV
fi
}

for i in "${VERSIONS_FILES[@]}"; do
while IFS=',' read -r output chain folder; do
boldprint "Check if the wasm sources changed for $chain"
simnode_check $output $folder $chain
done <<< "$i"
done <<<"$i"
done

# dropped through. there's something wrong; exit 1.
Expand Down
6 changes: 2 additions & 4 deletions .maintain/client_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
#shellcheck source=../common/lib.sh
. "$(dirname "${0}")/./common/lib.sh"

RELEASE_VERSION=$(git tag --sort=committerdate | grep -E '^v[0-9]' | tail -1 )
RELEASE_VERSION=$(git tag --sort=committerdate | grep -E '^v[0-9]' | tail -1)
# Because this script runs when a tag has been published, the previous tag is the
# last two tags
PREV_TAG=$(gh release list -L=2 | sed -n '2 p' | awk '{print $(NF-1)}')


if has_client_changes "${PREV_TAG}" "${GITHUB_REF_NAME}"
then
if has_client_changes "${PREV_TAG}" "${GITHUB_REF_NAME}"; then
boldprint "Building new client binaries"
cargo build --release -p composable
tar -czvf composable-"${RELEASE_VERSION}".tar.gz target/release/composable
Expand Down
Loading

0 comments on commit 06dd757

Please sign in to comment.