-
Notifications
You must be signed in to change notification settings - Fork 431
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrating the measurement and publish workflows to GitHub Actions (#1971
) * Add CI with measurements job * Fixed fmt * Removed dependency on the branch name * code refactored * Fixed upstream repo url * Added publish workflow * Disabled gitlab codecov and contract-sizes * Enabled codecov in GHA * Added tokens for codecov * Fixed token * Disabled docs push to gh-pages * Disabled docs push to gh-pages * Cancel in-progress jobs when new commit is added to PR
- Loading branch information
Showing
6 changed files
with
164 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,4 +44,4 @@ runs: | |
} | ||
- run: unzip data.zip -d ./${{ inputs.DOWNLOAD_DIR }} | ||
shell: bash | ||
shell: bash |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: continuous-intergration/measurements | ||
|
||
on: | ||
workflow_call: | ||
|
||
env: | ||
CARGO_TARGET_DIR: /ci-cache/${{ github.repository }}/targets/${{ github.ref_name }}/${{ github.job }} | ||
|
||
jobs: | ||
contract-sizes: | ||
if: ${{ github.event_name == 'pull_request' }} | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
container: | ||
image: paritytech/ci-unified:bullseye-1.73.0 | ||
strategy: | ||
fail-fast: false | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Cache | ||
uses: Swatinem/rust-cache@v2 | ||
with: | ||
cache-directories: ${{ env.CARGO_TARGET_DIR }} | ||
|
||
- name: Rust Info | ||
uses: ./.github/rust-info | ||
|
||
- name: Measure Contract Sizes | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
run: | | ||
# Variables | ||
MEASUREMENTS_DIR="${GITHUB_WORKSPACE}/../ink-ci-measurements" | ||
SCRIPTS_DIR="${GITHUB_WORKSPACE}/scripts" | ||
ARTIFACTS_DIR="${GITHUB_WORKSPACE}/artifacts" | ||
PR_CONTRACT_SIZES="${MEASUREMENTS_DIR}/pull_request_contract_sizes" | ||
UPSTREAM_BRANCH="master" | ||
UPSTREAM_CONTRACT_SIZES="${MEASUREMENTS_DIR}/${UPSTREAM_BRANCH}_contract_sizes" | ||
UPSTREAM_REPO="https://github.com/paritytech/ink.git" | ||
UPSTREAM_DIR="${MEASUREMENTS_DIR}/ink-${UPSTREAM_BRANCH}" | ||
CONTRACT_SIZES_DIFF="${MEASUREMENTS_DIR}/contract_sizes_diff.md" | ||
# Measure contract sizes for the current branch | ||
mkdir ${MEASUREMENTS_DIR} | ||
${SCRIPTS_DIR}/for_all_contracts_exec.sh --path integration-tests --quiet -- ${SCRIPTS_DIR}/contract_size.sh {} > ${PR_CONTRACT_SIZES} | ||
sed -ie 's/^integration-tests\///g' ${PR_CONTRACT_SIZES} | ||
# Measure contract sizes for the upstream branch | ||
git clone --verbose --depth 1 --branch ${UPSTREAM_BRANCH} ${UPSTREAM_REPO} ${UPSTREAM_DIR} | ||
pushd ${UPSTREAM_DIR} | ||
${SCRIPTS_DIR}/for_all_contracts_exec.sh --path integration-tests --quiet -- ${SCRIPTS_DIR}/contract_size.sh {} > ${UPSTREAM_CONTRACT_SIZES} | ||
sed -ie 's/^integration-tests\///g' ${UPSTREAM_CONTRACT_SIZES} | ||
popd | ||
# Build the comparison table | ||
${SCRIPTS_DIR}/contract_sizes_diff.sh ${UPSTREAM_CONTRACT_SIZES} ${PR_CONTRACT_SIZES} > ${CONTRACT_SIZES_DIFF} | ||
cat ${CONTRACT_SIZES_DIFF} | ||
# Create job artifact | ||
mkdir ${ARTIFACTS_DIR} | ||
mv ${CONTRACT_SIZES_DIFF} ${ARTIFACTS_DIR}/ | ||
CARGO_CONTRACT_VERSION=$(cargo-contract --version | egrep --only-matching "cargo-contract.* .*-x86" | sed -s 's/-x86//') | ||
echo "CARGO_CONTRACT_VERSION=\"${CARGO_CONTRACT_VERSION}\"" > ${ARTIFACTS_DIR}/context.out | ||
echo "PR_NUMBER=\"${PR_NUMBER}\"" >> ${ARTIFACTS_DIR}/context.out | ||
rm -rf ${MEASUREMENTS_DIR} | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.job }}-data | ||
path: ./artifacts | ||
retention-days: 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: continuous-intergration/publish-docs | ||
|
||
on: | ||
workflow_run: | ||
workflows: | ||
- continuous-integration | ||
types: | ||
- completed | ||
|
||
jobs: | ||
publish-docs: | ||
if: > | ||
github.event.workflow_run.event == 'push' && | ||
github.event.workflow_run.head_branch == 'master' && | ||
github.event.workflow_run.conclusion == 'success' | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 100 | ||
|
||
- name: Download Contract Sizes | ||
uses: ./.github/download-artifact | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
ARTIFACT_NAME: docs-data | ||
DOWNLOAD_DIR: crate-docs | ||
|
||
- name: Push docs | ||
run: | | ||
# Set git config | ||
git config user.email "[email protected]" | ||
git config user.name "paritytech-ci" | ||
git fetch origin gh-pages | ||
# saving README and docs | ||
cp -r ./crate-docs/ /tmp/doc/ | ||
cp ./README.md /tmp/doc/ | ||
cp -r ./.images/ /tmp/doc/ | ||
git checkout gh-pages | ||
mv _config.yml /tmp/doc/ | ||
# remove everything and restore generated docs, README and Jekyll config | ||
rm -rf ./* | ||
rm -rf ./.images | ||
mv /tmp/doc/* . | ||
mv /tmp/doc/.images . | ||
# Upload files | ||
git add --all --force | ||
git status | ||
# `git commit` has an exit code of > 0 if there is nothing to commit. | ||
# This unfortunately causes Github to exit immediately and mark this | ||
# job as failed subsequently. | ||
# We don't want to mark the entire job as failed if there's nothing to | ||
# publish though, hence the `|| true`. | ||
git commit -m "Updated docs for ${{ github.event.workflow_run.head_branch }}} and pushed to gh-pages" || true | ||
# TODO: Publish disabled, It will be enabled in last migration step | ||
# git push origin gh-pages --force | ||
rm -rf .git/ ./* |
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