File tree Expand file tree Collapse file tree 7 files changed +149
-0
lines changed
Expand file tree Collapse file tree 7 files changed +149
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ cargo install --locked cargo-audit
6+
7+ cargo audit --color always
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ rustup component add rustfmt
6+
7+ cargo fmt -- --check
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ # Dependencies: jq
4+
5+ set -eo pipefail
6+
7+ # Print version of given workspace package.
8+ get_version () {
9+ if [[ -z $1 ]]; then
10+ echo >&2 " name argument is mandatory"
11+ exit 1
12+ fi
13+ local name=" $1 "
14+ version=$( cargo metadata --format-version 1 --no-deps | jq ' .packages[] | select(.name == "' " $name " ' ") | {version}' | jq --exit-status -r .version)
15+ if [[ ! $version =~ ^[0-9] ]]; then
16+ echo >&2 " invalid version for ${name} : ${version} "
17+ exit 1
18+ fi
19+ echo " $version "
20+ }
21+
22+ main () {
23+ get_version " $1 "
24+ }
25+
26+ main " $@ "
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ cargo install --locked cargo-outdated
6+
7+ cargo outdated --root-deps-only --exit-code 1
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ CI_TOOLS_DIR=" $( dirname " ${BASH_SOURCE[0]} " ) "
6+ BASELINE_GIT_REF_FILE=" ${CI_TOOLS_DIR} /../../.semver-baseline"
7+
8+ apt-get update
9+ apt-get install -y --no-install-recommends cmake
10+ cargo install --locked cargo-semver-checks
11+
12+ baseline=" $( cat " ${BASELINE_GIT_REF_FILE} " ) "
13+ echo " Baseline Git rev: ${baseline} "
14+ env SQLX_OFFLINE=" true" cargo semver-checks --baseline-rev " $baseline "
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ export CI=" true" # https://insta.rs/docs/quickstart/#continuous-integration
6+
7+ sysinfo () {
8+ echo " System information:"
9+ uname -a
10+ rustc --version
11+ cargo --version
12+ echo " CARGO_HOME=${CARGO_HOME} "
13+ echo " .cargo/config.toml content:"
14+ echo " ---"
15+ cat " ${CARGO_HOME} /config.toml"
16+ echo " ---"
17+ echo " Environment variables:"
18+ printenv | sort
19+ }
20+
21+ install_test_deps () {
22+ echo " Initialising test dependencies"
23+ apt-get update -yq
24+ apt-get install -yq --no-install-recommends wireguard-tools
25+ }
26+
27+ lint () {
28+ echo " Linting"
29+ rustup component add clippy
30+ cargo clippy --all-features --color always -- --deny warnings --forbid unsafe_code
31+ }
32+
33+ tests () {
34+ echo " Testing"
35+ install_test_deps
36+ cargo test --color=always -- --color=always # <https://github.com/rust-lang/cargo/issues/11581#issuecomment-1382870899>
37+ cargo test --color=always -- --color=always --ignored # slow tests
38+ }
39+
40+ build () {
41+ cargo build --color always
42+ }
43+
44+ main () {
45+ sysinfo
46+ build
47+ lint
48+ tests
49+ }
50+
51+ main " $@ "
Original file line number Diff line number Diff line change 1+ name : GitHub Actions Demo
2+ on : [push]
3+ # env:
4+ # CARGO_HOME: "${CI_PROJECT_DIR}/.cargo" # necessary for dependency caching
5+
6+ # default:
7+ # cache:
8+ # key: "$CI_JOB_NAME" # not using Cargo.lock as key file: it changes too often
9+ # paths: [ .cargo/ ]
10+ # unprotect: true # publish job is "protected" because it runs only on main
11+ defaults :
12+ run :
13+ working-directory : ./.github/ci-tools
14+
15+ jobs :
16+ format :
17+ runs-on : rust-1.82
18+ # NOTE: Rust compiler versions are backward compatible, but updated clippy
19+ # can block a previously working job, pinning version to grant more reproducibility
20+ steps :
21+ - name : Check formatting
22+ run : ./format
23+ # cache: []
24+
25+ semver :
26+ runs-on : rust-1.82
27+ if : github.ref == 'refs/heads/master' # only on `master` branch
28+ steps :
29+ - name : Check semver
30+ run : ./semver
31+
32+ test :
33+ runs-on : rust-1.82
34+ steps :
35+ - name : Run tests
36+ run : ./test
37+ # not splitting lint (clippy) and test in two jobs to avoid wasting environment preparation time
You can’t perform that action at this time.
0 commit comments