Skip to content

Commit 7e50dce

Browse files
authored
Merge pull request #84 from crate-ci/add-nightly-only
Add nightly-only template
2 parents 38f20d7 + 95a26ab commit 7e50dce

File tree

2 files changed

+135
-2
lines changed

2 files changed

+135
-2
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ code compiles with and without any features it may have, and ensures
2121
that your code works with an older Rust version. You can also
2222
mix-and-match these checks if you wish.
2323

24-
The repository provides two main templates:
24+
The repository provides three main templates:
2525

2626
- `default.yml`, which is a highly opinionated default CI that you can
2727
use for most "normal" Rust projects.
28+
- `nightly-only.yml`, which is a highly opinionated default CI that you
29+
can use for Rust projects that only support nightly versions of Rust.
2830
- `install-rust.yml`, a minimal template that just installs Rust and
2931
has you write out the commands you want CI to run (see
3032
`default.yml` for inspiration). You can specify a Rust version,
@@ -253,7 +255,7 @@ with
253255
Then you can tweak it to your heart's desire!
254256

255257
There are some smaller configuration parameters available for `default.yml`
256-
too:
258+
too. Most of these also apply to `nightly-only.yml`.
257259

258260
### Testing on multiple platforms
259261

@@ -285,6 +287,20 @@ you would give that version number as the `minrust` parameter to
285287
`default.yml`. If you wish to disable the MSRV check, set `minrust`
286288
to `false`.
287289

290+
#### Minimum supported nightly
291+
292+
If you are using the `nightly-only.yml` template, the equivalent of MSRV
293+
checking is to check that you support some particular "oldest" nightly.
294+
You can check this by specifying a date for the `min` parameter:
295+
296+
```yaml
297+
jobs:
298+
- template: nightly-only.yml@templates
299+
parameters:
300+
minrust: <false | YYYY-MM-DD> = false
301+
```
302+
303+
288304
### Environment variables
289305

290306
```yaml

nightly-only.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
parameters:
2+
min: false
3+
setup: []
4+
services: {}
5+
env: {}
6+
cross: true
7+
dir: "."
8+
9+
jobs:
10+
- job: style
11+
displayName: Style linting
12+
pool:
13+
vmImage: ubuntu-18.04
14+
continueOnError: true
15+
steps:
16+
# latest nightly may not have rustfmt/clippy
17+
# we can't check for both:
18+
# https://github.com/rust-lang/rustup-components-history/issues/9
19+
# but we at least check for one.
20+
# rustfmt _seems_ to break most often:
21+
- bash: |
22+
echo '##vso[task.setvariable variable=nightly]nightly-'$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/rustfmt)
23+
displayName: "Determine latest style nightly"
24+
- template: install-rust.yml
25+
parameters:
26+
rust: $(nightly)
27+
components:
28+
- rustfmt
29+
- clippy
30+
# Run any user-specific setup steps
31+
- ${{ parameters.setup }}
32+
- script: cargo fmt --all -- --check
33+
workingDirectory: ${{ parameters.dir }}
34+
displayName: cargo fmt --check
35+
- script: cargo clippy --all
36+
workingDirectory: ${{ parameters.dir }}
37+
displayName: cargo clippy -- -D warnings
38+
- job: main
39+
displayName: Compile and test
40+
dependsOn: []
41+
${{ if eq('true', parameters.cross) }}:
42+
strategy:
43+
matrix:
44+
Linux:
45+
vmImage: ubuntu-18.04
46+
rust: nightly
47+
MacOS:
48+
vmImage: macOS-10.15
49+
rust: nightly
50+
Windows:
51+
vmImage: windows-2019
52+
rust: nightly
53+
${{ if ne('true', parameters.cross) }}:
54+
strategy:
55+
matrix:
56+
Linux:
57+
vmImage: ubuntu-18.04
58+
rust: nightly
59+
pool:
60+
vmImage: $(vmImage)
61+
services:
62+
${{ insert }}: ${{ parameters.services }}
63+
steps:
64+
- template: install-rust.yml
65+
parameters:
66+
rust: $(rust)
67+
# Run any user-specific setup steps
68+
- ${{ parameters.setup }}
69+
- script: cargo check
70+
workingDirectory: ${{ parameters.dir }}
71+
displayName: cargo check
72+
- script: cargo check --no-default-features
73+
workingDirectory: ${{ parameters.dir }}
74+
displayName: cargo check --no-default-features
75+
- script: cargo check --all-features
76+
workingDirectory: ${{ parameters.dir }}
77+
displayName: cargo check --all-features
78+
- script: cargo test --all-features
79+
workingDirectory: ${{ parameters.dir }}
80+
displayName: cargo test
81+
env:
82+
${{ insert }}: ${{ parameters.env }}
83+
- script: cargo doc --no-deps
84+
workingDirectory: ${{ parameters.dir }}
85+
displayName: cargo doc
86+
- ${{ if ne('false', parameters.min) }}:
87+
- job: msrv
88+
displayName: "${{ format('Minimum supported Rust nightly: {0}', parameters.min) }}"
89+
dependsOn: []
90+
# This represents the minimum Rust version supported.
91+
# Tests are not run as tests may require newer versions of nightly.
92+
pool:
93+
vmImage: ubuntu-18.04
94+
steps:
95+
- template: install-rust.yml
96+
parameters:
97+
rust: "${{ format('nightly-{0}', parameters.min) }}"
98+
# Run any user-specific setup steps
99+
- ${{ parameters.setup }}
100+
- script: cargo check
101+
workingDirectory: ${{ parameters.dir }}
102+
displayName: cargo check
103+
- script: cargo check --no-default-features
104+
workingDirectory: ${{ parameters.dir }}
105+
displayName: cargo check --no-default-features
106+
- script: cargo check --all-features
107+
workingDirectory: ${{ parameters.dir }}
108+
displayName: cargo check --all-features
109+
- ${{ if ne('', parameters.codecov_token) }}:
110+
- template: coverage.yml
111+
parameters:
112+
token: ${{ parameters.codecov_token }}
113+
setup: ${{ parameters.setup }}
114+
services: ${{ parameters.services }}
115+
env: ${{ parameters.env }}
116+
dir: ${{ parameters.dir }}
117+
nightly: true

0 commit comments

Comments
 (0)