Debian Codegraph @

debian/rust-vendor/parse_datetime/.github/workflows/ci.yml

raw
1 on: [push, pull_request]
2
3 name: Basic CI
4
5 env:
6 CARGO_INCREMENTAL: "0"
7 CARGO_TERM_COLOR: always
8 RUST_MIN_SRV: "1.71.1"
9
10 jobs:
11 check:
12 name: cargo check
13 runs-on: ${{ matrix.os }}
14 strategy:
15 matrix:
16 os: [ubuntu-latest, macOS-latest, windows-latest]
17 steps:
18 - uses: actions/checkout@v7
19 - run: cargo check
20
21 test:
22 name: cargo test
23 runs-on: ${{ matrix.os }}
24 strategy:
25 matrix:
26 os: [ubuntu-latest, macOS-latest, windows-latest]
27 steps:
28 - uses: actions/checkout@v7
29 - run: cargo test
30
31 fmt:
32 name: cargo fmt --all -- --check
33 runs-on: ubuntu-latest
34 steps:
35 - uses: actions/checkout@v7
36 - run: cargo fmt --all -- --check
37
38 clippy:
39 name: cargo clippy -- -D warnings
40 runs-on: ${{ matrix.os }}
41 strategy:
42 matrix:
43 os: [ubuntu-latest, macOS-latest, windows-latest]
44 steps:
45 - uses: actions/checkout@v7
46 - run: cargo clippy --all-targets -- -D warnings
47
48 min_version:
49 name: Minimum Supported Rust Version
50 runs-on: ${{ matrix.os }}
51 strategy:
52 matrix:
53 os: [ubuntu-latest, macOS-latest, windows-latest]
54 steps:
55 - uses: actions/checkout@v7
56 - uses: dtolnay/rust-toolchain@stable
57 with:
58 toolchain: ${{ env.RUST_MIN_SRV }}
59 - run: cargo check
60
61 coverage:
62 name: Code Coverage
63 runs-on: ${{ matrix.job.os }}
64 strategy:
65 fail-fast: true
66 matrix:
67 job:
68 - { os: ubuntu-latest , features: unix }
69 - { os: macos-latest , features: macos }
70 - { os: windows-latest , features: windows }
71 steps:
72 - uses: actions/checkout@v7
73 - name: emulate nightly toolchain
74 run: echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
75 - name: Initialize workflow variables
76 id: vars
77 shell: bash
78 run: |
79 ## VARs setup
80 outputs() { step_id="vars"; for var in "$@" ; do echo steps.${step_id}.outputs.${var}="${!var}"; echo "${var}=${!var}" >> $GITHUB_OUTPUT; done; }
81 # * specify gnu-type TOOLCHAIN for windows; `grcov` requires gnu-style code coverage data files
82 case ${{ matrix.job.os }} in windows-*) TOOLCHAIN="$TOOLCHAIN-x86_64-pc-windows-gnu" ;; esac;
83 # * use requested TOOLCHAIN if specified
84 if [ -n "${{ matrix.job.toolchain }}" ]; then TOOLCHAIN="${{ matrix.job.toolchain }}" ; fi
85 outputs TOOLCHAIN
86 # target-specific options
87 # * CODECOV_FLAGS
88 CODECOV_FLAGS=$( echo "${{ matrix.job.os }}" | sed 's/[^[:alnum:]]/_/g' )
89 outputs CODECOV_FLAGS
90
91 - name: rust toolchain ~ install
92 uses: dtolnay/rust-toolchain@nightly # this job is not reproducible...
93 with:
94 components: llvm-tools-preview
95 - name: Test
96 run: cargo test --no-fail-fast
97 env:
98 RUSTC_WRAPPER: ""
99 RUSTFLAGS: "-Cinstrument-coverage -Zcoverage-options=branch -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
100 RUSTDOCFLAGS: "-Cpanic=abort"
101 LLVM_PROFILE_FILE: "parse_datetime-%p-%m.profraw"
102 - name: "`grcov` ~ install"
103 id: build_grcov
104 shell: bash
105 run: |
106 git clone --depth=1 https://github.com/mozilla/grcov.git ~/grcov/
107 cd ~/grcov
108 # Hardcode the version of crossbeam-epoch. See
109 # https://github.com/uutils/coreutils/issues/3680
110 sed -i -e "s|tempfile =|crossbeam-epoch = \"=0.9.8\"\ntempfile =|" Cargo.toml
111 cargo install --path . --locked
112 cd -
113 # Uncomment when the upstream issue
114 # https://github.com/mozilla/grcov/issues/849 is fixed
115 # uses: actions-rs/[email protected]
116 # with:
117 # crate: grcov
118 # version: latest
119 # use-tool-cache: false
120 - name: Generate coverage data (via `grcov`)
121 id: coverage
122 shell: bash
123 run: |
124 ## Generate coverage data
125 COVERAGE_REPORT_DIR="target/debug"
126 COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
127 mkdir -p "${COVERAGE_REPORT_DIR}"
128 # display coverage files
129 grcov . --binary-path="${COVERAGE_REPORT_DIR}" --output-type files --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
130 # generate coverage report
131 grcov . --binary-path="${COVERAGE_REPORT_DIR}" --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" --source-dir .
132 echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
133 - name: Upload coverage results (to Codecov.io)
134 uses: codecov/codecov-action@v7
135 with:
136 token: ${{ secrets.CODECOV_TOKEN }}
137 files: ${{ steps.coverage.outputs.report }}
138 flags: ${{ steps.vars.outputs.CODECOV_FLAGS }}
139 name: codecov-umbrella
140 fail_ci_if_error: false
141 verbose: true
142 directory: ./
143 root_dir: ./
144
145 fuzz:
146 name: Run the fuzzers
147 runs-on: ubuntu-latest
148 env:
149 RUN_FOR: 60
150 steps:
151 - uses: actions/checkout@v7
152 - name: emulate nightly toolchain
153 run: echo "RUSTC_BOOTSTRAP=1" >> "${GITHUB_ENV}"
154 - name: Install `cargo-fuzz`
155 run: cargo install cargo-fuzz --locked
156 - uses: Swatinem/rust-cache@v2
157 - name: Run fuzz_parse_datetime for XX seconds
158 shell: bash
159 run: |
160 ## Run it
161 cd fuzz
162 cargo fuzz run fuzz_parse_datetime -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0
163 - name: Run fuzz_large_year for XX seconds
164 shell: bash
165 run: |
166 ## Run it
167 cd fuzz
168 cargo fuzz run fuzz_large_year -- -max_total_time=${{ env.RUN_FOR }} -detect_leaks=0