Skip to content

Commit 4605df1

Browse files
authored
Merge pull request #8 from actions-rust-lang/sparse-registry
2 parents 045ad9f + eac5ebb commit 4605df1

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ jobs:
1515
matrix:
1616
rust: [
1717
# Test with toolchain file override
18-
"1.50",
18+
"1.60",
19+
# Test that the sparse registry check works.
20+
# 1.66 and 1.67 don't support stable sparse registry.
21+
"1.66",
1922
"nightly",
2023
"beta",
2124
"stable",
@@ -27,13 +30,13 @@ jobs:
2730
run: |
2831
cat <<EOF >>rust-toolchain.toml
2932
[toolchain]
30-
channel = "nightly-2020-07-10"
33+
channel = "nightly-2022-09-10"
3134
components = [ "rustfmt", "rustc-dev" ]
3235
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
3336
profile = "minimal"
3437
EOF
3538
shell: bash
36-
if: matrix.rust == '1.50'
39+
if: matrix.rust == '1.60'
3740

3841
- uses: ./
3942
name: Run actions-rust-lang/setup-rust-toolchain ${{matrix.rust}}
@@ -48,3 +51,10 @@ jobs:
4851
run: echo '${{steps.toolchain.outputs.rustup-version}}'
4952
- run: rustc --version && cargo --version
5053
shell: bash
54+
55+
# Test with creating a small project
56+
- run: cargo init . --bin --name ci
57+
# Add tiny empty crate.
58+
# This checks that registry access works.
59+
- run: cargo add serde_as
60+
- run: cargo check

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
* Only set environment variables, if they are not set before.
1313
This allows setting environment variables before using this action and keeping their values.
14-
14+
* Enable stable sparse registry, except on versions 1.66 and 1.67 where this leads to errors.
15+
1516
## [1.3.7] - 2023-01-31
1617

1718
### Fixed

action.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ runs:
7878
if [[ ! -v CARGO_UNSTABLE_SPARSE_REGISTRY ]]; then
7979
echo "CARGO_UNSTABLE_SPARSE_REGISTRY=true" >> $GITHUB_ENV
8080
fi
81-
# Enable sparse index after stabilization
82-
# This causes warnings on stable 1.67, e.g., when using "cargo add"
83-
# https://github.com/rust-lang/cargo/pull/11224
84-
# echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV
8581
shell: bash
8682
- name: "Install Rust Problem Matcher"
8783
run: echo "::add-matcher::${{ github.action_path }}/rust.json"
@@ -123,6 +119,18 @@ runs:
123119
echo "cachekey=$(echo $DATE$HASH | head -c12)" >> $GITHUB_OUTPUT
124120
shell: bash
125121

122+
# Copied from dtolnay/rust-toolchain and adapted
123+
# https://github.com/dtolnay/rust-toolchain/blob/25dc93b901a87e864900a8aec6c12e9aa794c0c3/action.yml#L100-L108
124+
- name: "Enable cargo sparse registry on stable"
125+
run: |
126+
# except on 1.66 and 1.67, on which it is unstable
127+
if [[ ! -v CARGO_REGISTRIES_CRATES_IO_PROTOCOL ]]; then
128+
if echo "${{steps.versions.outputs.rustc-version}}" | not grep -q '^rustc 1\.6[67]\.'; then
129+
echo "CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse" >> $GITHUB_ENV
130+
fi
131+
fi
132+
shell: bash
133+
126134
- name: "Setup Rust Caching"
127135
if: inputs.cache == 'true'
128136
uses: Swatinem/rust-cache@v2

0 commit comments

Comments
 (0)