diff --git a/.github/download-artifact/action.yml b/.github/download-artifact/action.yml index 8c44d03587d..66d5ef653aa 100644 --- a/.github/download-artifact/action.yml +++ b/.github/download-artifact/action.yml @@ -44,4 +44,4 @@ runs: } - run: unzip data.zip -d ./${{ inputs.DOWNLOAD_DIR }} - shell: bash \ No newline at end of file + shell: bash diff --git a/.github/rust-info/action.yml b/.github/rust-info/action.yml index cdf4953a78f..76fd89b76a9 100644 --- a/.github/rust-info/action.yml +++ b/.github/rust-info/action.yml @@ -1,7 +1,7 @@ -name: 'Rust Info' -description: "Rust and Bash details" +name: Rust Info +description: Rust and Bash details runs: - using: "composite" + using: composite steps: - run: | rustup show diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d901f6560a..c0445783f0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,11 @@ env: # later. For example, `riscv32imc-unknown-none-elf`. RISCV_TARGET: riscv32i-unknown-none-elf +concurrency: + # Cancel in-progress jobs triggered only on pull_requests + group: ${{ github.head_ref || github.run_id }} + cancel-in-progress: true + ### lint jobs: @@ -396,7 +401,7 @@ jobs: - uses: actions/upload-artifact@v3 with: - name: ${{ github.job }}_${{ github.sha }}-doc + name: ${{ github.job }}-data path: ./crate-docs retention-days: 7 @@ -414,7 +419,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 with: - fetch-depth: 100 + fetch-depth: 0 - name: Rust Info uses: ./.github/rust-info @@ -434,15 +439,19 @@ jobs: # The `cargo-taurpalin` coverage reporting tool seems to have better code instrumentation and thus # produces better results for Rust codebases in general. However, unlike `grcov` it requires # running docker with `--security-opt seccomp=unconfined` which is why we use `grcov` instead. + CODECOV_P_TOKEN: ${{ secrets.CODECOV_P_TOKEN }} + CODECOV_L_TOKEN: ${{ secrets.CODECOV_L_TOKEN }} run: | # RUSTFLAGS are the cause target cache can't be used here - # FIXME: cust-covfix doesn't support the external target dir + # FIXME: rust-covfix doesn't support the external target dir # https://github.com/Kogia-sima/rust-covfix/issues/7 unset "CARGO_TARGET_DIR" cargo clean # make sure there's no stale coverage artifacts find . -name "*.profraw" -type f -delete find . -name "*.gcda" -type f -delete + # FIXME: Access from 2 users, should be solved once ci-image works from a non-root user + git config --global --add safe.directory '*' # RUSTFLAGS are the cause target cache can't be used here cargo build --verbose --all-features --workspace cargo test --verbose --all-features --no-fail-fast --workspace @@ -450,14 +459,12 @@ jobs: grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm --branch \ --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-w-branch.info rust-covfix lcov-w-branch.info --output lcov-w-branch-fixed.info - # TODO: Enable when Gitlab CI is disabled - #codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero + codecov --token "$CODECOV_P_TOKEN" --file lcov-w-branch-fixed.info --nonZero # lines coverage grcov . --binary-path ./target/debug/ --source-dir . --output-type lcov --llvm \ --ignore-not-existing --ignore "/*" --ignore "tests/*" --output-path lcov-lines.info rust-covfix lcov-lines.info --output lcov-lines-fixed.info - # TODO: Enable when Gitlab CI is disabled - #codecov --token "$CODECOV_TOKEN" --file lcov-lines-fixed.info --nonZero + codecov --token "$CODECOV_L_TOKEN" --file lcov-lines-fixed.info --nonZero ### examples @@ -587,3 +594,9 @@ jobs: scripts/for_all_contracts_exec.sh --path integration-tests -- cargo doc --manifest-path {} \ --document-private-items --verbose --no-deps +# measurements + + measurements: + needs: [examples-docs, examples-contract-build, examples-test] + uses: ./.github/workflows/measurements.yml + diff --git a/.github/workflows/measurements.yml b/.github/workflows/measurements.yml new file mode 100644 index 00000000000..5409baf0eb1 --- /dev/null +++ b/.github/workflows/measurements.yml @@ -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 diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 00000000000..47b2d191189 --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -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 "paritytech-ci@parity.io" + 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/ ./* diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b7c870aa1d..72ce5464269 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -290,7 +290,7 @@ docs: - chown -R nonroot:nonroot ./crate-docs -codecov: +.codecov: stage: workspace <<: *docker-env <<: *test-refs @@ -415,7 +415,7 @@ examples-docs: #### stage: measurements -contract-sizes: +.contract-sizes: stage: measurements <<: *docker-env rules: