Skip to content

Commit

Permalink
update actions
Browse files Browse the repository at this point in the history
Make datatest-stable like quick-junit.
  • Loading branch information
sunshowers committed Apr 8, 2024
1 parent 0b3cff8 commit abcf3b0
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 43 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,72 @@ on:
- main

name: CI
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
- name: Lint (rustfmt)
run: cargo xfmt --check
- name: Lint (clippy)
run: cargo clippy --all-features --all-targets
- name: Lint (rustfmt)
run: cargo xfmt --check
- name: Install cargo readme
uses: taiki-e/install-action@834a7b93e0c678fb40309ee0e36546336d5c6ea7 # v2
with:
tool: cargo-readme
- name: Run cargo readme
run: ./scripts/regenerate-readmes.sh
- name: Check for differences
run: git diff --exit-code

build-rustdoc:
name: Build documentation
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
- name: Build rustdoc
run: cargo doc --all-features

build:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os:
- ubuntu-latest
# 1.60 is the MSRV
rust-version: [ "1.60", stable ]
rust-version: ["1.60", stable]
fail-fast: false
env:
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: dtolnay/rust-toolchain@1482605bfc5719782e1267fd0c0cc350fe7646b8 # v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2
with:
key: ${{ matrix.rust-version }}
- name: Build
run: cargo build
- name: Install nextest
- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Test
run: cargo nextest run --all-features
- name: Delete Cargo.lock and test against latest versions
if: matrix.rust-version == 'stable'
run: |
rm Cargo.lock
cargo nextest run --all-features
- name: Build datatest-stable
run: cargo build
- name: Run tests
run: cargo nextest run
44 changes: 44 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
on:
push:
branches:
- main
pull_request:
branches:
- main

name: Test coverage

jobs:
coverage:
name: Collect test coverage
runs-on: ubuntu-latest
# nightly rust might break from time to time
continue-on-error: true
env:
RUSTFLAGS: -D warnings
CARGO_TERM_COLOR: always
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
# Nightly Rust is used for cargo llvm-cov --doc below.
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2

- name: Install latest nextest release
uses: taiki-e/install-action@nextest
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

- name: Collect coverage data
# Generate separate reports for nextest and doctests, and combine them.
run: |
cargo llvm-cov --no-report nextest
cargo llvm-cov --no-report --doc
cargo llvm-cov report --doctests --lcov --output-path lcov.info
- name: Upload coverage data to codecov
uses: codecov/codecov-action@c16abc29c95fcf9174b58eb7e1abf4c866893bc8 # v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
26 changes: 13 additions & 13 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@ name: Docs
jobs:
docs:
name: Build and deploy documentation
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1
with:
toolchain: stable
- name: Build rustdoc
uses: actions-rs/cargo@844f36862e911db73fe0815f00a4a2602c279505 # v1
with:
command: doc
args: --all-features
- uses: dtolnay/rust-toolchain@stable
- name: Build rustdocs
run: ./scripts/build-docs.sh
- name: Organize
run: |
rm -rf target/gh-pages
mkdir target/gh-pages
mv target/doc/_redirects target/gh-pages
mv target/doc target/gh-pages/rustdoc
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
- name: Publish
uses: cloudflare/pages-action@1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: target/gh-pages
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: datatest-stable
directory: target/gh-pages
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
25 changes: 13 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# adapted from https://github.com/taiki-e/cargo-hack/blob/main/.github/workflows/release.yml

name: Publish release
name: Publish releases to GitHub
on:
push:
tags:
- '*'
- "*"

jobs:
create-release:
if: github.repository_owner == 'nextest-rs'
datatest-stable-release:
if: github.repository_owner == 'nextest-rs' && startsWith(github.ref_name, 'datatest-stable-')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
persist-credentials: false
- name: Install Rust
uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1
uses: dtolnay/rust-toolchain@stable
- name: Install cargo release
uses: taiki-e/install-action@834a7b93e0c678fb40309ee0e36546336d5c6ea7 # v2
with:
toolchain: stable
override: true
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
tool: [email protected]
- uses: taiki-e/create-gh-release-action@8df4de6534ceacdaed10a08f73418ca751f31793 # v1
with:
prefix: datatest-stable
changelog: CHANGELOG.md
title: datatest-stable $version
title: $prefix $version
branch: main
prefix: datatest-stable
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: ./scripts/cargo-release-publish.sh
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
2 changes: 1 addition & 1 deletion README.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ license](LICENSE-MIT).
README.md is generated from README.tpl by cargo readme. To regenerate:
cargo install cargo-readme
cargo readme > README.md
./scripts/regenerate-readmes.sh
-->
12 changes: 12 additions & 0 deletions scripts/build-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

# Build docs for all crates and direct dependencies. The gawk script turns e.g. "quick-junit v0.1.0"
# into "[email protected]".
cargo tree --depth 1 -e normal --prefix none \
| gawk '{ gsub(" v", "@", $0); printf("%s\n", $1); }' \
| xargs printf -- '-p %s\n' \
| xargs cargo doc --no-deps --lib

# Also drop a _redirects file in the root of the docs directory -- this will be picked up by the
# CI script.
echo "/ /rustdoc/datatest_stable/ 301" > target/doc/_redirects
16 changes: 16 additions & 0 deletions scripts/cargo-release-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# Use cargo-release to publish crates to crates.io.

set -xe -o pipefail

# cargo-release requires a release off a branch (maybe it shouldn't?)
# Check out this branch, creating it if it doesn't exist.
git checkout -B to-release

# --execute: actually does the release
# --no-confirm: don't ask for confirmation, since this is a non-interactive script
cargo release publish --publish --execute --no-confirm --workspace "$@"

git checkout -
git branch -D to-release

0 comments on commit abcf3b0

Please sign in to comment.