Skip to content

Commit

Permalink
Actions refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
shimkiv committed Aug 29, 2024
1 parent fc56510 commit 592fffa
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 106 deletions.
20 changes: 20 additions & 0 deletions .github/actions/ocaml-shared/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Shared OCaml setting up steps"
description: "Shared OCaml setting up steps"
inputs:
ocaml_version:
description: "OCaml version"
required: true
shell:
description: "Shell to use"
required: false
default: "bash"
runs:
using: "composite"
steps:
- name: Setup OCaml ${{ inputs.ocaml_version }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ inputs.ocaml_version }}
# https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386
# disable-cache: true
shell: ${{ inputs.shell }}
26 changes: 26 additions & 0 deletions .github/actions/toolchain-shared/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Shared Rust toolchain setting up steps"
description: "Shared Rust toolchain setting up steps"
inputs:
rust_toolchain_version:
description: "Rust toolchain version"
required: true
shell:
description: "Shell to use"
required: false
default: "bash"
runs:
using: "composite"
steps:
# As action-rs does not seem to be maintained anymore, building from
# scratch the environment using rustup
- name: Setup Rust toolchain ${{ inputs.rust_toolchain_version }}
run: |
curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \
https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x ./rustup-init
./rustup-init -y --default-toolchain "${{ inputs.rust_toolchain_version }}" --profile default
rm ./rustup-init
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# overwriting default rust-toolchain
echo ${{ inputs.rust_toolchain_version }} > rust-toolchain
shell: ${{ inputs.shell }}
63 changes: 63 additions & 0 deletions .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#
# This workflow is triggered nightly (or on-demand) to run all the tests with the code coverage enabled and using the self-hosted GitHub runner.
#

name: Nightly tests with code coverage

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch: {}

env:
# https://doc.rust-lang.org/cargo/reference/profiles.html#release
RUSTFLAGS: -Coverflow-checks=y -Cdebug-assertions=y
# https://doc.rust-lang.org/cargo/reference/profiles.html#incremental
CARGO_INCREMENTAL: 1
# https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions
CARGO_TERM_COLOR: always
RUST_MIN_STACK: 31457280
# 30 MB of stack for Keccak tests

jobs:
run_tests:
name: Run all tests with the code coverage
runs-on: ${{ matrix.os }}
strategy:
matrix:
# FIXME: use the latest version of cargo nextest when we get rid of 1.71
# and 1.72
rust_toolchain_version: ["1.74"]
# FIXME: currently not available for 5.0.0.
# It might be related to boxroot dependency, and we would need to bump
# up the ocaml-rs dependency
ocaml_version: ["4.14"]
os: ["hetzner-1"]
steps:
- name: Checkout PR
uses: actions/checkout@v4.1.1

- name: Use shared Rust toolchain setting up steps
uses: ./.github/actions/toolchain-shared
with:
rust_toolchain_version: ${{ matrix.rust_toolchain_version }}

- name: Use shared OCaml setting up steps
uses: ./.github/actions/ocaml-shared
with:
ocaml_version: ${{ matrix.ocaml_version }}

- name: Install test dependencies
run: |
make install-test-deps
- name: Run all tests
if: ${{ matrix.rust_toolchain_version == '1.74' }}
run: |
eval $(opam env)
make nextest-all-with-coverage
- name: Use shared Codecov reporting steps
uses: ./.github/actions/codecov-shared
with:
token: ${{ secrets.CODECOV_TOKEN }}
94 changes: 32 additions & 62 deletions .github/workflows/rust.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,10 @@ jobs:
- name: Checkout PR
uses: actions/checkout@v4.1.1

- name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }}
run: |
curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \
https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x ./rustup-init
./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default
rm ./rustup-init
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# overwriting default rust-toolchain
echo ${{ matrix.rust_toolchain_version }} > rust-toolchain
- name: Use shared Rust toolchain setting up steps
uses: ./.github/actions/toolchain-shared
with:
rust_toolchain_version: ${{ matrix.rust_toolchain_version }}

- name: Build the mdbook
run: |
Expand All @@ -51,33 +45,20 @@ jobs:
- name: Checkout PR
uses: actions/checkout@v4.1.1

- name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }}
run: |
curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \
https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x ./rustup-init
./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default
rm ./rustup-init
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# overwriting default rust-toolchain
echo ${{ matrix.rust_toolchain_version }} > rust-toolchain
- name: Use shared Rust toolchain setting up steps
uses: ./.github/actions/toolchain-shared
with:
rust_toolchain_version: ${{ matrix.rust_toolchain_version }}

- name: Run cargo fmt
run: |
make format
# We run only one of the matrix options on the toffee hetzner-1,
# and also only in this configuration we enable heavy tests.
run-checks-setup:
runs-on: ubuntu-latest
outputs:
runners: '{"1.71":"ubuntu-latest", "1.72": "ubuntu-latest", "1.73": "ubuntu-latest", "1.74": "hetzner-1"}'
steps:
- run: echo no-op

run_checks:
needs: [run-checks-setup]

name: Run some basic checks and tests
runs-on: ${{ matrix.os }}
env:
RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74"
strategy:
matrix:
# FIXME: use the latest version of cargo nextest when we get rid of 1.71
Expand All @@ -87,34 +68,20 @@ jobs:
# It might be related to boxroot dependency, and we would need to bump
# up the ocaml-rs dependency
ocaml_version: ["4.14"]

# See run-checks-setup
runs-on: ${{ fromJSON(needs.run-checks-setup.outputs.runners)[matrix.rust_toolchain_version] }}

name: Run some basic checks and tests
os: ["ubuntu-latest"]
steps:
- name: Checkout PR
uses: actions/checkout@v4.1.1

# as action-rs does not seem to be maintained anymore, building from
# scratch the environment using rustup
- name: Setup Rust toolchain ${{ matrix.rust_toolchain_version }}
run: |
curl --proto '=https' --tlsv1.2 -sSf -o rustup-init \
https://static.rust-lang.org/rustup/dist/x86_64-unknown-linux-gnu/rustup-init
chmod +x ./rustup-init
./rustup-init -y --default-toolchain "${{ matrix.rust_toolchain_version }}" --profile default
rm ./rustup-init
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
# overwriting default rust-toolchain
echo ${{ matrix.rust_toolchain_version }} > rust-toolchain
- name: Setup OCaml ${{ matrix.ocaml_version }}
uses: ocaml/setup-ocaml@v2
- name: Use shared Rust toolchain setting up steps
uses: ./.github/actions/toolchain-shared
with:
rust_toolchain_version: ${{ matrix.rust_toolchain_version }}

- name: Use shared OCaml setting up steps
uses: ./.github/actions/ocaml-shared
with:
ocaml-compiler: ${{ matrix.ocaml_version }}
# https://github.com/ocaml/setup-ocaml/issues/211#issuecomment-1058882386
# disable-cache: true
ocaml_version: ${{ matrix.ocaml_version }}

- name: Install markdownlint
run: |
Expand Down Expand Up @@ -165,7 +132,7 @@ jobs:
- name: Ensure that everything builds
run: |
eval $(opam env)
make all
make
#
# Tests
Expand All @@ -175,21 +142,24 @@ jobs:
run: |
make install-test-deps
- name: Run non-heavy tests
- name: Run non-heavy tests without the code coverage
if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }}
run: |
eval $(opam env)
make nextest
- name: Run non-heavy tests with the code coverage
if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }}
run: |
eval $(opam env)
make nextest-with-coverage
- name: Use shared Codecov reporting steps
if: ${{ matrix.rust_toolchain_version == env.RUST_TOOLCHAIN_COVERAGE_VERSION }}
uses: ./.github/actions/codecov-shared
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Run heavy tests
if: ${{ matrix.rust_toolchain_version == '1.74' }}
run: |
eval $(opam env)
make nextest-heavy
- name: Doc tests
run: |
eval $(opam env)
Expand Down
44 changes: 0 additions & 44 deletions .github/workflows/coverage.yml.disabled

This file was deleted.

0 comments on commit 592fffa

Please sign in to comment.