|
2 | 2 | # More info: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses
|
3 | 3 |
|
4 | 4 | # Common Rust CI setup that checkout the repo, installs the common toolchain
|
5 |
| -# and set's up the cargo cache. It builds, tests, and lints the code. |
| 5 | +# and set's up the cargo cache. It builds, tests, and lints the code, but is |
| 6 | +# configurable. This way, the same workflow can be used to build, test, and lint |
| 7 | +# all in different steps, but with the same cache. |
6 | 8 |
|
7 | 9 | on:
|
8 | 10 | workflow_call:
|
9 | 11 | inputs:
|
| 12 | + runs-on: |
| 13 | + type: string |
| 14 | + required: false |
| 15 | + default: ubuntu-latest |
| 16 | + description: | |
| 17 | + The value for the "runs-on" property: e.g. |
| 18 | + - ubuntu-latest |
| 19 | + - windows-latest |
10 | 20 | rust-version:
|
11 | 21 | type: string
|
12 | 22 | required: false
|
|
22 | 32 | required: false
|
23 | 33 | # Make sure we always an empty string to "--features <FEATURES>"
|
24 | 34 | default: '""'
|
25 |
| - description: Comma-separated String with additional Rust features relevant for a certain job. |
| 35 | + description: > |
| 36 | + Comma-separated string with additional crate features. Empty string by |
| 37 | + default. CAUTION: For Windows CI runners, this must be '""' as is, |
| 38 | + i.e., the string itself must be "". This is a limitation of the |
| 39 | + Windows power shell. This might be configured like this: |
| 40 | +
|
| 41 | + features: > |
| 42 | + '""' |
26 | 43 | do-style-check:
|
27 | 44 | type: boolean
|
28 | 45 | required: false
|
|
35 | 52 | description: Execute tests.
|
36 | 53 |
|
37 | 54 | jobs:
|
38 |
| - check_rust: |
39 |
| - runs-on: ubuntu-latest |
| 55 | + rust: |
| 56 | + runs-on: ${{ inputs.runs-on }} |
40 | 57 | steps:
|
41 | 58 | - name: Check out
|
42 | 59 | uses: actions/checkout@v3
|
@@ -67,16 +84,23 @@ jobs:
|
67 | 84 | - name: Build (all targets)
|
68 | 85 | run: cargo build --all-targets --features ${{ inputs.features }}
|
69 | 86 | - name: Code Formatting
|
70 |
| - if: ${{ inputs.do-style-check }} |
| 87 | + if: inputs.do-style-check |
71 | 88 | run: cargo fmt --all -- --check
|
72 | 89 | - name: Code Style and Doc Style
|
73 |
| - if: ${{ inputs.do-style-check }} |
| 90 | + if: inputs.do-style-check |
74 | 91 | run: |
|
75 | 92 | cargo doc --document-private-items --features ${{ inputs.features }}
|
76 | 93 | cargo clippy --all-targets --features ${{ inputs.features }}
|
77 |
| - - name: Unit Test |
78 |
| - if: ${{ inputs.do-test }} |
| 94 | + - name: Unit Test (UNIX) |
| 95 | + if: inputs.do-test && runner.os != 'Windows' |
79 | 96 | run: |
|
80 | 97 | curl -LsSf https://get.nexte.st/latest/linux | tar zxf -
|
81 | 98 | chmod u+x cargo-nextest
|
82 | 99 | ./cargo-nextest nextest run --features ${{ inputs.features }}
|
| 100 | + - name: Unit Test (Windows) |
| 101 | + if: inputs.do-test && runner.os == 'Windows' |
| 102 | + run: | |
| 103 | + Invoke-WebRequest https://get.nexte.st/latest/windows -OutFile cargo-nextest.zip |
| 104 | + Expand-Archive .\cargo-nextest.zip |
| 105 | + cp .\cargo-nextest/cargo-nextest.exe . |
| 106 | + .\cargo-nextest.exe nextest run --features ${{ inputs.features }} |
0 commit comments