Skip to content

Commit 29ab05e

Browse files
committed
Add CI
1 parent 9b20c72 commit 29ab05e

File tree

5 files changed

+133
-0
lines changed

5 files changed

+133
-0
lines changed

.github/workflows/build.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Continuous Integration Checks
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- master
7+
pull_request:
8+
branches-ignore:
9+
- master
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build:
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
platform: [ ubuntu-latest, windows-latest, macos-latest ]
21+
toolchain: [ stable, beta, 1.63.0 ] # 1.63.0 is the MSRV
22+
exclude:
23+
- platform: windows-latest
24+
toolchain: 1.63.0
25+
runs-on: ${{ matrix.platform }}
26+
steps:
27+
- name: Checkout source code
28+
uses: actions/checkout@v4
29+
- name: Install Rust ${{ matrix.toolchain }} toolchain
30+
run: |
31+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ matrix.toolchain }}
32+
rustup override set ${{ matrix.toolchain }}
33+
- name: shellcheck the CI and `contrib` scripts
34+
if: "matrix.platform == 'ubuntu-latest'"
35+
run: |
36+
sudo apt-get -y install shellcheck
37+
shellcheck ci/*.sh -aP ci
38+
- name: Set RUSTFLAGS to deny warnings
39+
if: "matrix.toolchain == '1.63.0'"
40+
run: echo "RUSTFLAGS=-D warnings" >> "$GITHUB_ENV"
41+
- name: Run CI script
42+
shell: bash # Default on Winblows is powershell
43+
run: ./ci/ci-tests.sh
44+
45+
linting:
46+
runs-on: ubuntu-latest
47+
env:
48+
TOOLCHAIN: stable
49+
steps:
50+
- name: Checkout source code
51+
uses: actions/checkout@v4
52+
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
53+
run: |
54+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
55+
rustup override set ${{ env.TOOLCHAIN }}
56+
- name: Install clippy
57+
run: |
58+
rustup component add clippy
59+
- name: Run default clippy linting
60+
run: |
61+
./ci/check-lint.sh
62+
63+
rustfmt:
64+
runs-on: ubuntu-latest
65+
env:
66+
TOOLCHAIN: 1.63.0
67+
steps:
68+
- name: Checkout source code
69+
uses: actions/checkout@v4
70+
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
71+
run: |
72+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
73+
rustup override set ${{ env.TOOLCHAIN }}
74+
- name: Install rustfmt
75+
run: |
76+
rustup component add rustfmt
77+
- name: Run rustfmt checks
78+
run: ci/rustfmt.sh

ci/check-lint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e
3+
set -x
4+
RUSTFLAGS='-D warnings' cargo clippy

ci/ci-tests.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
5+
6+
# Starting with version 1.39.0, the `tokio` crate has an MSRV of rustc 1.70.0
7+
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p tokio --precise "1.38.1" --verbose
8+
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p tokio-util --precise "0.7.10" --verbose
9+
10+
# idna_adapter 1.2 switched to ICU4X, requiring 1.81 and newer
11+
[ "$RUSTC_MINOR_VERSION" -lt 81 ] && cargo update -p idna_adapter --precise "1.1.0" --verbose
12+
13+
[ "$RUSTC_MINOR_VERSION" -lt 70 ] && cargo update -p once_cell --precise "1.20.3" --verbose
14+
15+
[ "$RUSTC_MINOR_VERSION" -lt 65 ] && cargo update -p [email protected] --precise "0.15.0" --verbose
16+
17+
export RUST_BACKTRACE=1
18+
19+
cargo check --verbose --color always
20+
cargo check --release --verbose --color always
21+
cargo test
22+
cargo test --features http
23+
cargo test --features std
24+
cargo doc --document-private-items --no-default-features
25+
cargo doc --document-private-items --features http,std

ci/rustfmt.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# The +rustversion syntax only works with rustup-installed rust toolchains,
5+
# not with any distro-provided ones. Thus, we check for a rustup install and
6+
# only pass +1.63.0 if we find one.
7+
VERS=""
8+
[ "$(which rustup)" != "" ] && VERS="+1.63.0"
9+
10+
# Run fmt
11+
for file in $(git ls-files | grep '.rs$'); do
12+
echo "Checking formatting of $file"
13+
rustfmt $VERS --edition 2021 --check "$file"
14+
done

rustfmt.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use_small_heuristics = "Max"
2+
fn_args_layout = "Compressed"
3+
hard_tabs = true
4+
use_field_init_shorthand = true
5+
max_width = 100
6+
match_block_trailing_comma = true
7+
# UNSTABLE: format_code_in_doc_comments = true
8+
# UNSTABLE: overflow_delimited_expr = true
9+
# UNSTABLE: comment_width = 100
10+
# UNSTABLE: format_macro_matchers = true
11+
# UNSTABLE: format_strings = true
12+
# UNSTABLE: group_imports = "StdExternalCrate"

0 commit comments

Comments
 (0)