Skip to content

Commit 5a71134

Browse files
authored
ci(refactor_jobs): split the job into several jobs (#11)
* ci(refactor_jobs): split the job into several jobs * add the nightly toolchain jobs * Fixed main.rs fmt error
1 parent c29285b commit 5a71134

File tree

2 files changed

+138
-10
lines changed

2 files changed

+138
-10
lines changed

.github/workflows/rust.yml

Lines changed: 137 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,151 @@ name: Rust
33
on:
44
push:
55
branches: [ main ]
6+
tags:
7+
- '*'
68
pull_request:
79
branches: [ main ]
810

911
env:
1012
CARGO_TERM_COLOR: always
1113

1214
jobs:
13-
build:
15+
fmt:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
21+
- name: Install latest stable
22+
uses: actions-rs/toolchain@v1
23+
with:
24+
toolchain: stable
25+
override: true
26+
components: rustfmt
27+
28+
- name: Check code format
29+
run: cargo fmt --all -- --check
30+
31+
stable-build:
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v3
36+
37+
- name: Install latest stable
38+
uses: actions-rs/toolchain@v1
39+
with:
40+
toolchain: stable
41+
override: true
42+
components: rustfmt, clippy
43+
44+
- name: Build debug
45+
run: cargo build --verbose
46+
47+
- name: Build release
48+
run: cargo build --release --verbose
49+
50+
- uses: actions/cache@v2
51+
id: stable-cargo-build
52+
with:
53+
path: |
54+
~/.cargo/bin/
55+
~/.cargo/registry/index/
56+
~/.cargo/registry/cache/
57+
~/.cargo/git/db/
58+
target/
59+
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
60+
61+
stable-tests:
62+
runs-on: ubuntu-latest
63+
needs: ['stable-build']
64+
steps:
65+
- name: Restore cache
66+
uses: actions/cache@v2
67+
id: stable-cargo-build
68+
with:
69+
path: |
70+
~/.cargo/bin/
71+
~/.cargo/registry/index/
72+
~/.cargo/registry/cache/
73+
~/.cargo/git/db/
74+
target/
75+
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
1476

77+
- name: Checkout repository
78+
uses: actions/checkout@v3
79+
80+
- name: Install latest stable
81+
uses: actions-rs/toolchain@v1
82+
with:
83+
toolchain: stable
84+
override: true
85+
components: rustfmt, clippy
86+
87+
- name: Cargo test debug
88+
run: cargo test --all-features --verbose
89+
90+
- name: Cargo test release
91+
run: cargo test --release --all-features --verbose
92+
93+
nightly-build:
1594
runs-on: ubuntu-latest
95+
steps:
96+
- name: Checkout repository
97+
uses: actions/checkout@v3
98+
99+
- name: Install latest nightly
100+
uses: actions-rs/toolchain@v1
101+
with:
102+
toolchain: nightly
103+
override: true
104+
components: rustfmt, clippy
105+
106+
- name: Build debug
107+
run: cargo build --verbose
16108

109+
- name: Build release
110+
run: cargo build --release --verbose
111+
112+
- uses: actions/cache@v2
113+
id: nightly-cargo-build
114+
with:
115+
path: |
116+
~/.cargo/bin/
117+
~/.cargo/registry/index/
118+
~/.cargo/registry/cache/
119+
~/.cargo/git/db/
120+
target/
121+
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
122+
123+
nightly-tests:
124+
runs-on: ubuntu-latest
125+
needs: ['nightly-build']
17126
steps:
18-
- uses: actions/checkout@v3
19-
- name: Build
20-
run: cargo build --verbose
21-
- name: Run tests
22-
run: cargo test --verbose
127+
- name: Restore cache
128+
uses: actions/cache@v2
129+
id: nightly-cargo-build
130+
with:
131+
path: |
132+
~/.cargo/bin/
133+
~/.cargo/registry/index/
134+
~/.cargo/registry/cache/
135+
~/.cargo/git/db/
136+
target/
137+
key: ${{ runner.os }}-stable-cargo-${{ hashFiles('**/Cargo.lock') }}
138+
139+
- name: Checkout repository
140+
uses: actions/checkout@v3
141+
142+
- name: Install latest nightly
143+
uses: actions-rs/toolchain@v1
144+
with:
145+
toolchain: nightly
146+
override: true
147+
components: rustfmt, clippy
148+
149+
- name: Cargo test debug
150+
run: cargo test --all-features --verbose
151+
152+
- name: Cargo test release
153+
run: cargo test --release --all-features --verbose

src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ fn main() {
112112
}
113113
};
114114

115-
Station {
116-
station: x,
117-
url,
118-
}
115+
Station { station: x, url }
119116
}
120117

121118
// Otherwise

0 commit comments

Comments
 (0)