-
-
Notifications
You must be signed in to change notification settings - Fork 138
136 lines (129 loc) · 3.97 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: CI
on:
repository_dispatch:
workflow_dispatch:
push:
branches:
- master
tags:
- "*.*.*"
pull_request:
types:
- opened
- synchronize
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: make test
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Run cargo fmt (check if all code is rustfmt-ed)
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
- name: Run cargo clippy (deny warnings)
uses: actions-rs/cargo@v1
with:
command: clippy
# --all-targets makes it lint tests too
args: --all-targets --all-features -- -D warnings
publish-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo publish lychee-lib
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --dry-run --manifest-path lychee-lib/Cargo.toml
# Can't check lychee binary as it depends on the lib above
# and `--dry-run` doesn't allow unpublished crates yet.
# https://github.com/rust-lang/cargo/issues/1169
# `cargo-publish-all` is a solution but it doesn't work with
# Rust edition 2021.
# Therefore skip the check for now, which is probably fine
# because the binary is just a small wrapper around the CLI
# anyway.
#
# - name: cargo publish lychee
# uses: actions-rs/cargo@v1
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# with:
# command: publish
# args: --dry-run --manifest-path lychee-bin/Cargo.toml
publish:
if: startsWith(github.ref, 'refs/tags/')
needs:
- test
- lint
- check-feature-flags
- publish-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: cargo fetch
uses: actions-rs/cargo@v1
with:
command: fetch
- name: cargo publish lychee-lib
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --manifest-path lychee-lib/Cargo.toml
- name: Wait for crates.io publication
run: sleep 60s
shell: bash
- name: cargo publish lychee
uses: actions-rs/cargo@v1
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
with:
command: publish
args: --manifest-path lychee-bin/Cargo.toml
check-feature-flags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check that rustls-tls feature doesn't depend on OpenSSL
run: test -z "$( cargo tree --package lychee --no-default-features --features rustls-tls --prefix none | sed -n '/^openssl-sys /p' )"
- name: Run cargo check with default features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets
- name: Run cargo check with all features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --all-features
- name: Run cargo check with rustls-tls feature
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --no-default-features --features rustls-tls