66 pull_request :
77 workflow_dispatch :
88
9+ schedule :
10+ # Run at 05:00 UTC every day
11+ - cron : ' 0 5 * * *'
12+
913env :
1014 CARGO_TERM_COLOR : always
1115 RUSTFLAGS : -Dwarnings
12- RUSTDOCFLAGS : -Dwarnings
1316 RUST_BACKTRACE : 1
14- MSRV : 1.79.0
17+ # note: MSRV now tracked in `rust-toolchain.toml`
1518
1619jobs :
17- build :
18- runs-on : ubuntu-latest
19- steps :
20- - uses : actions/checkout@v4
21- - run : rustup show active-toolchain -v
22- - run : cargo build --all-targets
23- - run : cargo build --all-targets --no-default-features
24- - run : cargo build --all-targets --all-features
25-
26- msrv :
27- runs-on : ubuntu-latest
28- env :
29- RUSTFLAGS : " " # remove -Dwarnings
30- steps :
31- - uses : actions/checkout@v4
32- - run : rustup toolchain install ${{ env.MSRV }} --profile minimal
33- - run : rustup override set ${{ env.MSRV }}
34- - run : rustup show active-toolchain -v
35- # URL 2.5.4 -> ICU4X 2.x require rustc 1.82
36- # See https://github.com/servo/rust-url?tab=readme-ov-file#alternative-unicode-back-ends
37- # https://github.com/hsivonen/idna_adapter?tab=readme-ov-file#icu4x-as-the-default
38- - run : cargo update -p idna_adapter --precise 1.2.0
39- - run : cargo update -p native-tls --precise 0.2.13 # 0.2.14 requires rustc 1.80
40- - run : cargo update -p litemap --precise 0.7.4 # 0.7.5 requires rustc 1.81
41- - run : cargo update -p zerofrom --precise 0.1.5 # 0.1.6 requires rustc 1.81
42- - run : cargo update -p lz4_flex --precise 0.11.3 # 0.11.4 requires rustc 1.81
43- - run : cargo update -p url --precise 2.5.0 # 2.5.4 requires rustc 1.82
44- - run : cargo update -p time --precise 0.3.41 # 0.3.43 requires rustc 1.81
45- - run : cargo update -p time-core --precise 0.1.4 # 0.1.6 requires rustc 1.81
46- - run : cargo update -p deranged --precise 0.4.0 # 0.5.x requires rustc 1.81
47- - run : cargo build
48- - run : cargo build --no-default-features
49- - run : cargo build --features uuid,time,chrono
50- - run : cargo build --all-features
51-
52- rustfmt :
53- runs-on : ubuntu-latest
54- steps :
55- - uses : actions/checkout@v4
56- - run : rustup show active-toolchain -v
57- - run : rustup component add rustfmt
58- - run : cargo fmt --version
59- - run : cargo fmt -- --check
60-
20+ # Clippy ensures successful compilation as well,
21+ # so we do not need a separate build check
6122 clippy :
6223 runs-on : ubuntu-latest
6324 steps :
6425 - uses : actions/checkout@v4
26+ - uses : Swatinem/rust-cache@v2
27+
6528 - run : rustup show active-toolchain -v
6629 - run : rustup component add clippy
6730 - run : cargo clippy --version
31+
6832 - run : cargo clippy
6933 - run : cargo clippy --all-targets --no-default-features
7034 - run : cargo clippy --all-targets --all-features
@@ -77,89 +41,117 @@ jobs:
7741 - run : cargo clippy --features rustls-tls-aws-lc,rustls-tls-webpki-roots
7842 - run : cargo clippy --features rustls-tls-aws-lc,rustls-tls-native-roots
7943
44+ rustfmt :
45+ runs-on : ubuntu-latest
46+ steps :
47+ - uses : actions/checkout@v4
48+ # no cache - it does not compile anything
49+
50+ - run : rustup show active-toolchain -v
51+ - run : rustup component add rustfmt
52+ - run : cargo fmt --version
53+ - run : cargo fmt -- --check
54+
8055 docs :
81- needs : build
8256 runs-on : ubuntu-latest
83- env :
84- RUSTDOCFLAGS : -Dwarnings --cfg docsrs
8557 steps :
8658 - uses : actions/checkout@v4
59+ # no cache since it uses nightly toolchain
60+
8761 - run : rustup toolchain install nightly
8862 - run : rustup override set nightly
8963 - run : rustup show active-toolchain -v
90- - run : cargo doc --all-features
64+ # Serde 1.0.227 fails to build with `--cfg docsrs`, only pass it to our own packages
65+ - run : cargo rustdoc -p clickhouse-macros --all-features -- -D warnings --cfg docsrs
66+ - run : cargo rustdoc -p clickhouse-types --all-features -- -D warnings --cfg docsrs
67+ - run : cargo rustdoc -p clickhouse --all-features -- -D warnings --cfg docsrs
9168
92- test :
69+ miri :
9370 runs-on : ubuntu-latest
9471 steps :
9572 - uses : actions/checkout@v4
73+ # no cache since Miri uses nightly and its own special instrumentation
9674
97- - name : Install cargo-llvm-cov
98- uses : taiki-e/install-action@cargo-llvm-cov
75+ - run : rustup toolchain install nightly --component miri
76+ - run : rustup override set nightly
77+ - run : rustup show active-toolchain -v
78+ - run : cargo miri setup
79+ - run : cargo miri test --all-features -- _miri
80+
81+ # uses a single local Docker container with a few ClickHouse versions
82+ test-local :
83+ runs-on : ubuntu-latest
84+ strategy :
85+ fail-fast : false
86+ matrix :
87+ clickhouse : [ latest, head ]
88+ include :
89+ - clickhouse : latest
90+ coverage : true
91+ steps :
92+ - uses : actions/checkout@v4
93+ - uses : Swatinem/rust-cache@v2
94+
95+ - uses : taiki-e/install-action@cargo-llvm-cov
9996
10097 - name : Start ClickHouse in Docker
10198 uses : hoverkraft-tech/compose-action@v2.2.0
10299 with :
103- compose-file : ' docker-compose.yml'
104- down-flags : ' --volumes'
105-
106- - run : rustup show active-toolchain -v
107- # TODO: --workspace won't be required after splitting workspace and the main crate
108- - name : Run tests
109- run : cargo llvm-cov test --workspace --no-report
110- - name : Run tests without default features
111- run : cargo llvm-cov test --workspace --no-report --no-default-features
112- - name : Run tests with all features
113- run : cargo llvm-cov test --workspace --no-report --all-features
114-
115- - name : Check access to GitHub secrets
116- id : check-secrets-access
117- run : |
118- if [[ "${{ github.actor }}" == "loyd" ]]; then
119- echo "has-access=true" >> $GITHUB_OUTPUT
120- echo "Paul Loyd is our VIP"
121- elif gh api orgs/ClickHouse/members/${{ github.actor }} --silent; then
122- echo "has-access=true" >> $GITHUB_OUTPUT
123- else
124- echo "has-access=false" >> $GITHUB_OUTPUT
125- fi
100+ compose-file : docker-compose.yml
101+ down-flags : --volumes
126102 env :
127- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
128- continue-on-error : true
103+ CLICKHOUSE_VERSION : ${{ matrix.clickhouse }}
104+
105+ - run : cargo llvm-cov test --workspace --no-report
106+ - run : cargo llvm-cov test --workspace --no-report --no-default-features
107+ - run : cargo llvm-cov test --workspace --no-report --all-features
108+
109+ # coverage upload requires access to secrets, so skip on community PRs
110+
111+ - name : Generate Codecov report
112+ if : ${{ matrix.coverage && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ClickHouse/clickhouse-rs') }}
113+ run : cargo llvm-cov report --codecov --output-path codecov.json
114+
115+ - name : Upload coverage to Codecov
116+ if : ${{ matrix.coverage && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ClickHouse/clickhouse-rs') }}
117+ uses : codecov/codecov-action@v5
118+ with :
119+ files : codecov.json
120+ flags : test-local-${{ matrix.clickhouse }}
121+ token : ${{ secrets.CODECOV_TOKEN }}
122+ slug : ClickHouse/clickhouse-rs
123+ fail_ci_if_error : false # don't fail on community PRs
124+
125+ # uses a shared ClickHouse Cloud instance, but that requires access to secrets
126+ # it is not possible for community PRs, as well as coverage upload in `test-local` job
127+ test-cloud :
128+ runs-on : ubuntu-latest
129129
130- - name : Run tests with ClickHouse Cloud
131- if : steps.check-secrets-access.outputs.has-access == 'true'
130+ # skipped for PRs from forks (no access to secrets)
131+ # allowing for merge commits, scheduled runs, etc.
132+ if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'ClickHouse/clickhouse-rs'
133+
134+ steps :
135+ - uses : actions/checkout@v4
136+ - uses : Swatinem/rust-cache@v2
137+
138+ - uses : taiki-e/install-action@cargo-llvm-cov
139+
140+ - name : Run Cloud tests
132141 env :
133142 CLICKHOUSE_TEST_ENVIRONMENT : cloud
134143 CLICKHOUSE_CLOUD_HOST : ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT }}
135144 CLICKHOUSE_CLOUD_PASSWORD : ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD_SMT }}
136145 CLICKHOUSE_CLOUD_JWT_ACCESS_TOKEN : ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_JWT_DESERT_VM_43 }}
137- # Temporary runs tests with `cloud_` prefix only until we validate that the rest of the tests are working
138- # `https_errors` should assert ClickHouse Cloud connection errors without enabled TLS features
139146 run : |
140147 cargo llvm-cov test cloud_ --no-report --features rustls-tls -- --nocapture
141148 cargo llvm-cov test https_errors --no-report -- --nocapture
142149
143- - name : Generate code coverage
144- if : steps.check-secrets-access.outputs.has-access == 'true'
145- run : cargo llvm-cov report --codecov --output-path codecov.json
146-
147- - name : Upload coverage to Codecov
148- uses : codecov/codecov-action@v5
149- if : steps.check-secrets-access.outputs.has-access == 'true'
150+ - run : cargo llvm-cov report --codecov --output-path codecov.json
151+ - uses : codecov/codecov-action@v5
150152 with :
151153 files : codecov.json
154+ flags : test-cloud
152155 token : ${{ secrets.CODECOV_TOKEN }}
153156 slug : ClickHouse/clickhouse-rs
154157 fail_ci_if_error : true
155-
156- miri :
157- needs : build
158- runs-on : ubuntu-latest
159- steps :
160- - uses : actions/checkout@v4
161- - run : rustup toolchain install nightly --component miri
162- - run : rustup override set nightly
163- - run : rustup show active-toolchain -v
164- - run : cargo miri setup
165- - run : cargo miri test --all-features -- _miri
0 commit comments