Skip to content

Commit 836f537

Browse files
committed
Restructure CI to prevent publishing a broken crate
Move build, lint, test, docs, and publish jobs into the same action. Require successful completion of build, test, lint, and docs before publishing a new version of the crate.
1 parent 61d5021 commit 836f537

File tree

5 files changed

+104
-148
lines changed

5 files changed

+104
-148
lines changed

.github/workflows/build.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,34 @@ on:
1212
workflow_dispatch:
1313

1414
jobs:
15+
lint:
16+
runs-on: ubuntu-latest
17+
env:
18+
RUST_LOG: info
19+
steps:
20+
- uses: styfle/[email protected]
21+
name: Cancel Outdated Builds
22+
with:
23+
all_but_latest: true
24+
access_token: ${{ github.token }}
25+
26+
- uses: actions/checkout@v4
27+
name: Checkout Repository
28+
29+
- uses: dtolnay/rust-toolchain@stable
30+
31+
- uses: Swatinem/rust-cache@v2
32+
name: Enable Rust Caching
33+
34+
- name: Format Check
35+
run: cargo fmt -- --check
36+
37+
- uses: actions-rs/clippy-check@v1
38+
name: Clippy
39+
with:
40+
token: ${{ github.token }}
41+
args: --workspace --all-features --all-targets -- -D warnings
42+
1543
build:
1644
runs-on: ubuntu-latest
1745
env:
@@ -46,3 +74,79 @@ jobs:
4674
github_token: ${{ secrets.GITHUB_TOKEN }}
4775
publish_dir: ./target/doc
4876
cname: tide-disco.docs.espressosys.com
77+
78+
test:
79+
runs-on: ubuntu-latest
80+
env:
81+
RUST_LOG: info
82+
steps:
83+
- uses: styfle/[email protected]
84+
name: Cancel Outdated Builds
85+
with:
86+
all_but_latest: true
87+
access_token: ${{ github.token }}
88+
89+
- uses: actions/checkout@v4
90+
name: Checkout Repository
91+
92+
- uses: dtolnay/rust-toolchain@stable
93+
94+
- uses: Swatinem/rust-cache@v2
95+
name: Enable Rust Caching
96+
97+
- name: Build tests
98+
run: cargo test --workspace --release --all-features --no-run
99+
100+
- name: Test
101+
run: cargo test --workspace --release --all-features --verbose -- --test-threads 2
102+
timeout-minutes: 60
103+
104+
docs:
105+
runs-on: ubuntu-latest
106+
env:
107+
RUST_LOG: info
108+
steps:
109+
- uses: styfle/[email protected]
110+
name: Cancel Outdated Builds
111+
with:
112+
all_but_latest: true
113+
access_token: ${{ github.token }}
114+
115+
- uses: actions/checkout@v4
116+
name: Checkout Repository
117+
118+
- uses: dtolnay/rust-toolchain@stable
119+
120+
- uses: Swatinem/rust-cache@v2
121+
name: Enable Rust Caching
122+
123+
- name: Generate Documentation
124+
run: |
125+
cargo doc --no-deps --lib --release --all-features
126+
echo '<meta http-equiv="refresh" content="0; url=base64_bytes">' > target/doc/index.html
127+
128+
- name: Deploy Documentation
129+
uses: peaceiris/actions-gh-pages@v3
130+
if: ${{ github.ref == 'refs/heads/main' }}
131+
with:
132+
github_token: ${{ secrets.GITHUB_TOKEN }}
133+
publish_dir: ./target/doc
134+
cname: base64-bytes.docs.espressosys.com
135+
136+
publish:
137+
needs:
138+
- build
139+
- test
140+
- lint
141+
- docs
142+
runs-on: ubuntu-latest
143+
steps:
144+
- uses: actions/checkout@v3
145+
- uses: actions-rs/toolchain@v1
146+
with:
147+
toolchain: stable
148+
override: true
149+
- uses: katyo/publish-crates@v2
150+
with:
151+
dry-run: ${{ github.event_name != 'push' }}
152+
ignore-unpublished-changes: true

.github/workflows/cargo-publish.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)