dev.yml #2211
Workflow file for this run
This file contains hidden or 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
# The primary point of this workflow is to ensure that the developer experience is good. | |
# We take a very vanilla ubuntu image, install all necessary dependencies via "normal" means, | |
# and then run the build and test steps as described in the README.md file. | |
# The artifacts produced by these builds are not intended to be used for anything other than | |
# ensuring that the developer experience is good. | |
# Production artifacts are produced in a sterile environment (in another CI workflow). | |
name: "dev.yml" | |
on: | |
pull_request: { } | |
push: | |
branches: | |
- "main" | |
merge_group: | |
types: [ "checks_requested" ] | |
workflow_dispatch: | |
inputs: | |
debug_enabled: | |
type: "boolean" | |
description: "Run with tmate enabled" | |
required: false | |
default: false | |
debug_justfile: | |
type: "boolean" | |
description: "enable to see debug statements from just recipes" | |
required: false | |
default: false | |
concurrency: | |
group: "${{ github.workflow }}:${{ github.event.pull_request.number || github.event.after || github.event.merge_group && github.run_id }}" | |
cancel-in-progress: true | |
permissions: | |
contents: "read" | |
packages: "write" | |
id-token: "write" | |
jobs: | |
check_changes: | |
name: "Deduce required tests from code changes" | |
permissions: | |
contents: "read" | |
pull-requests: "read" | |
runs-on: "ubuntu-latest" | |
outputs: | |
devfiles: "${{ steps.changes.outputs.devfiles }}" | |
steps: | |
- name: "Checkout" | |
if: "${{ !github.event.pull_request }}" | |
uses: "actions/checkout@v4" | |
with: | |
persist-credentials: "false" | |
fetch-depth: "0" | |
- name: "Check code changes" | |
uses: "dorny/paths-filter@v3" | |
id: "changes" | |
with: | |
filters: | | |
devfiles: | |
- '!(README.md|LICENSE|.gitignore|.github/**)' | |
- '.github/workflows/dev.yml' | |
check: | |
needs: [ check_changes ] | |
if: "${{ needs.check_changes.outputs.devfiles == 'true' }}" | |
permissions: | |
checks: "write" | |
pull-requests: "write" | |
contents: "read" | |
packages: "write" | |
id-token: "write" | |
strategy: | |
fail-fast: false | |
matrix: | |
profile: | |
- name: "debug" | |
sterile: "" | |
- name: "debug" | |
sterile: "sterile" | |
- name: "release" | |
sterile: "sterile" | |
- name: "fuzz" | |
sterile: "sterile" | |
#- name: "release" | |
# sterile: "" | |
#- name: "fuzz" | |
# sterile: "" | |
debug_justfile: | |
- "${{ inputs.debug_justfile || false }}" | |
name: "${{matrix.profile.name}} ${{matrix.profile.sterile}}" | |
runs-on: "lab" | |
timeout-minutes: 45 | |
steps: | |
- name: "login to ghcr.io" | |
uses: "docker/login-action@v3" | |
with: | |
registry: "ghcr.io" | |
username: "${{ github.actor }}" | |
password: "${{ secrets.GITHUB_TOKEN }}" | |
- name: "install rust" | |
uses: "dtolnay/rust-toolchain@master" | |
with: | |
toolchain: "stable" | |
targets: "x86_64-unknown-linux-gnu" | |
components: "rustfmt,clippy" | |
- name: "install cargo binstall" | |
uses: "cargo-bins/[email protected]" | |
- name: "Checkout" | |
uses: "actions/checkout@v4" | |
with: | |
persist-credentials: "false" | |
fetch-depth: "0" | |
- name: "install just" | |
run: | | |
cargo binstall --no-confirm just | |
- name: "set up compile-env" | |
run: | | |
just --yes debug_justfile="${{matrix.debug_justfile}}" refresh-compile-env | |
just --yes debug_justfile="${{matrix.debug_justfile}}" fake-nix | |
- name: "cargo deny check" | |
run: | | |
just debug_justfile="${{matrix.debug_justfile}}" ${{matrix.profile.sterile}} cargo deny check | |
- name: "push container" | |
if: ${{ matrix.profile.sterile == 'sterile' && (matrix.profile.name == 'release' || matrix.profile.name == 'debug') }} | |
run: | | |
just \ | |
debug_justfile="${{matrix.debug_justfile}}" \ | |
profile=${{matrix.profile.name}} \ | |
target=x86_64-unknown-linux-gnu \ | |
push-container | |
- id: "test" | |
name: "test" | |
run: | | |
set -euo pipefail | |
mkdir --parent ./target/nextest | |
if [ ${{ matrix.profile.name }} = "fuzz" ]; then | |
just \ | |
debug_justfile="${{matrix.debug_justfile}}" \ | |
profile=${{matrix.profile.name}} \ | |
target=x86_64-unknown-linux-gnu \ | |
${{matrix.profile.sterile}} coverage \ | |
--status-level=none \ | |
--final-status-level=skip \ | |
--message-format=libtest-json-plus > ./results.json | |
else | |
just \ | |
debug_justfile="${{matrix.debug_justfile}}" \ | |
profile=${{matrix.profile.name}} \ | |
target=x86_64-unknown-linux-gnu \ | |
${{matrix.profile.sterile}} cargo nextest run \ | |
--cargo-profile=${{matrix.profile.name}} \ | |
--status-level=none \ | |
--final-status-level=skip \ | |
--message-format=libtest-json-plus > ./results.json | |
fi | |
# look for any flakes (flakes have a #\\d+ match in their name field) | |
jq \ | |
--raw-output \ | |
--slurp '.[] | select(.type == "test" and (.name | test(".*#\\d+"))) | ( .name | split("#") ) | | |
[.[0], (.[1] | tonumber)] | @csv | |
' ./results.json > ./target/nextest/flakes.csv | |
if [ -s ./target/nextest/flakes.csv ]; then | |
{ | |
echo "FLAKY_TESTS<<EOF" | |
echo -e "### :warning: Flaky tests (${{matrix.profile.name}} - ${{matrix.profile.sterile}})\n"; | |
echo "| test | retries |" | |
echo "|------|---------|" | |
just cargo csview --style=markdown --no-headers --body-align=left ./target/nextest/flakes.csv; | |
echo "EOF" | |
} >> "${GITHUB_ENV}" | |
fi | |
rm results.json | |
- name: "upload test results to codecov" | |
if: ${{ always() }} | |
uses: "codecov/codecov-action@v5" | |
with: | |
fail_ci_if_error: true | |
files: ./target/nextest/default/junit.xml | |
report_type: "test_results" | |
disable_search: 'true' | |
use_oidc: 'true' | |
verbose: true | |
flags: "${{matrix.profile.name}}-${{ matrix.profile.sterile || 'developer' }}" | |
- name: "upload codecov analysis" | |
if: ${{ matrix.profile.name == 'fuzz' }} | |
uses: "codecov/codecov-action@v5" | |
with: | |
fail_ci_if_error: true | |
files: ./target/nextest/coverage/codecov.json | |
report_type: "coverage" | |
disable_search: 'true' | |
use_oidc: 'true' | |
verbose: true | |
flags: "${{matrix.profile.name}}-${{ matrix.profile.sterile || 'developer' }}" | |
- name: "clean up coverage data" | |
run: | | |
rm -f codecov codecov.SHA256SUM codecov.SHA256SUM.sig | |
- uses: "marocchino/sticky-pull-request-comment@v2" | |
if: ${{ always() }} | |
with: | |
header: "flakes_${{matrix.profile.name}}_${{matrix.profile.sterile}}" | |
ignore_empty: 'true' | |
message: | | |
${{ env.FLAKY_TESTS }} | |
- name: "publish test report" | |
uses: "mikepenz/action-junit-report@v5" | |
if: "${{ always() }}" | |
with: | |
annotate_notice: 'false' | |
annotate_only: 'false' | |
check_annotations: 'true' | |
check_retries: 'false' | |
comment: 'false' | |
detailed_summary: 'true' | |
fail_on_failure: 'false' | |
fail_on_parse_error: 'true' | |
flaky_summary: 'true' | |
include_empty_in_summary: 'true' | |
include_passed: 'true' | |
include_time_in_summary: 'true' | |
report_paths: 'target/nextest/default/*junit.xml' | |
require_passed_tests: 'true' | |
require_tests: 'true' | |
simplified_summary: 'true' | |
truncate_stack_traces: 'false' | |
group_reports: 'true' | |
check_name: "test-report-${{matrix.profile.name}}-sterile:${{matrix.profile.sterile == 'sterile'}}" | |
skip_success_summary: 'false' | |
job_summary: 'true' | |
verbose_summary: 'false' | |
- id: "clippy" | |
name: "run clippy" | |
run: | | |
just debug_justfile="${{matrix.debug_justfile}}" profile=${{matrix.profile.name}} \ | |
${{matrix.profile.sterile}} cargo clippy --all-targets --all-features -- -D warnings | |
- id: "docs" | |
name: "run rustdoc" | |
run: | | |
just \ | |
debug_justfile="${{matrix.debug_justfile}}" \ | |
profile=${{matrix.profile.name}} \ | |
target=x86_64-unknown-linux-gnu \ | |
${{matrix.profile.sterile}} cargo doc | |
- name: "Setup tmate session for debug" | |
if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
uses: "mxschmitt/action-tmate@v3" | |
timeout-minutes: 60 | |
with: | |
limit-access-to-actor: true | |
summary: | |
name: "Summary" | |
runs-on: "ubuntu-latest" | |
needs: | |
- check | |
steps: | |
- run: | | |
exit 0 |