ci: Revamp workflows to run with the configurations in mind and remov… #65
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
name: "Code coverage" | |
run-name: "Running code coverage for smart contracts" | |
on: | |
# workflow_dispatch: | |
# schedule: | |
# - cron: "0 0 * * *" | |
defaults: | |
run: | |
shell: "sh" | |
env: | |
CARGO_TERM_COLOR: "always" | |
RELEASE_VERSION: "ci" | |
jobs: | |
configuration: | |
runs-on: 'ubuntu-latest' | |
name: "Configuration" | |
outputs: | |
stable-rust-version: |- | |
${{ steps.configuration.outputs.stable-rust-version }} | |
nightly-rust-version: |- | |
${{ steps.configuration.outputs.nightly-rust-version }} | |
networks-json: |- | |
${{ steps.configuration.outputs.networks-json }} | |
protocols-json: |- | |
${{ steps.configuration.outputs.protocols-json }} | |
one-per-dex-protocols-json: |- | |
${{ steps.configuration.outputs.one-per-dex-protocols-json }} | |
steps: | |
- uses: "actions/checkout@v4" | |
- id: 'configuration' | |
uses: "./.github/actions/configuration" | |
install_crates-io_tooling: | |
runs-on: "ubuntu-latest" | |
strategy: | |
fail-fast: true | |
matrix: | |
tool: | |
# Add necessary tooling | |
- "cargo-tarpaulin" | |
### GitHub Actions escaped string | |
name: "Install tool [${{ matrix.tool }}; local: false]" | |
steps: | |
- uses: "actions/checkout@v4" | |
- uses: "./.github/actions/install-tool" | |
with: | |
no-fetching: "true" | |
fail-on-cache-miss: "false" | |
tool: |- | |
${{ matrix.tool }} | |
local: "false" | |
cache_rust_toolchains: | |
runs-on: "ubuntu-latest" | |
needs: | |
- "configuration" | |
name: "Cache stable Rust toolchain" | |
steps: | |
- uses: "actions/checkout@v4" | |
- id: "restore-cache" | |
uses: "./.github/actions/cache-rust" | |
with: | |
cache-cargo: "false" | |
cache-rust-stable: "true" | |
rust-stable: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
cache-rust-nightly: "false" | |
no-fetching: "true" | |
fail-on-cache-miss: "false" | |
cache_cargo_and_vendor_deps: | |
runs-on: "ubuntu-latest" | |
needs: | |
- "configuration" | |
- "cache_rust_toolchains" | |
strategy: | |
fail-fast: true | |
matrix: | |
working-directory: | |
- "platform" | |
- "protocol" | |
- "tests" | |
- "tools" | |
### GitHub Actions escaped string | |
name: "Cache Cargo and vendor dependencies [\ | |
${{ matrix.working-directory }}]" | |
steps: | |
- uses: "actions/checkout@v4" | |
- id: "restore-cache" | |
uses: "./.github/actions/cache-rust" | |
with: | |
cache-cargo: "true" | |
working-directory: |- | |
${{ matrix.working-directory }} | |
cache-rust-stable: "true" | |
rust-stable: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
cache-rust-nightly: "false" | |
no-fetching: "true" | |
fail-on-cache-miss: "false" | |
install_local_tooling: | |
runs-on: "ubuntu-latest" | |
needs: | |
- "configuration" | |
- "cache_rust_toolchains" | |
- "cache_cargo_and_vendor_deps" | |
strategy: | |
fail-fast: true | |
matrix: | |
tool: | |
# Add necessary tooling | |
- "cargo-each" | |
### GitHub Actions escaped string | |
name: "Install tool [${{ matrix.tool }}; local: true]" | |
steps: | |
- uses: "actions/checkout@v4" | |
- uses: "./.github/actions/install-tool" | |
with: | |
lookup-only: "true" | |
fail-on-cache-miss: "false" | |
tool: |- | |
${{ matrix.tool }} | |
local: "true" | |
rust-version: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
code_coverage: | |
runs-on: "ubuntu-latest" | |
needs: | |
- "configuration" | |
- "install_crates-io_tooling" | |
- "cache_rust_toolchains" | |
- "cache_cargo_and_vendor_deps" | |
- "install_local_tooling" | |
strategy: | |
fail-fast: false | |
matrix: | |
working_directory: | |
- "protocol" | |
- "tests" | |
### GitHub Actions escaped string | |
network: "${{ needs.configuration.outputs.networks-json }}" | |
### GitHub Actions escaped string | |
protocol: "${{ needs.configuration.outputs.protocols-json }}" | |
include: | |
- working_directory: "platform" | |
network: "@agnostic" | |
protocol: "@agnostic" | |
- working_directory: "tools" | |
network: "@agnostic" | |
protocol: "@agnostic" | |
name: "Code Coverage [${{ matrix.working_directory }}; \ | |
${{ matrix.network }}; ${{ matrix.protocol }}]" | |
steps: | |
- uses: "actions/[email protected]" | |
- uses: "./.github/actions/cache-rust" | |
with: | |
cache-cargo: "false" | |
cache-rust-stable: "true" | |
rust-stable: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
cache-rust-nightly: "false" | |
lookup-only: "false" | |
fail-on-cache-miss: "true" | |
- uses: "./.github/actions/install-tool" | |
with: | |
lookup-only: "false" | |
fail-on-cache-miss: "true" | |
tool: "cargo-tarpaulin" | |
local: "false" | |
- uses: "./.github/actions/install-tool" | |
with: | |
lookup-only: "false" | |
fail-on-cache-miss: "true" | |
tool: "cargo-each" | |
local: "true" | |
rust-version: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
- env: | |
stable_rust_version: |- | |
${{ needs.configuration.outputs.stable-rust-version }} | |
network: |- | |
${{ matrix.network }} | |
protocol: |- | |
${{ matrix.protocol }} | |
run: |- | |
cargo "+${stable_rust_version}" each run --print-command --tag ci \ | |
--tag "${network}" --tag "${protocol}" -- tarpaulin --out xml \ | |
>> "./output.log" | |
working-directory: |- | |
${{ matrix.working_directory }} | |
- name: "Produce code coverage summary" | |
run: | | |
echo -n "# Code coverage [${working_directory}; ${network}; \ | |
${protocol}]: " >> $GITHUB_STEP_SUMMARY | |
tail --lines=1 "./output.log" \ | |
| sed -r -e 's/^([0-9]+(\\.[0-9]+)?%).*/\\1/' \ | |
>> "${GITHUB_STEP_SUMMARY}" | |
working-directory: |- | |
${{ matrix.working_directory }} | |
env: | |
working-directory: |- | |
${{ matrix.working_directory }} | |
network: |- | |
${{ matrix.network }} | |
protocol: |- | |
${{ matrix.protocol }} |