Skip to content

Commit

Permalink
Add test for precompiled binary failing on Windows to CI (#389)
Browse files Browse the repository at this point in the history
* Add failing Windows test to CI (#2)

* Remove trailing whitespaces.

* Explain removing the index

* Add caching (#3)

* Convert slashes to back-slashes (#4)

* Bump crates-index version to 0.19.6
  • Loading branch information
mgr0dzicki authored Feb 25, 2023
1 parent f61f2a3 commit 37568fc
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 41 deletions.
132 changes: 132 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- run-on-ref-slice-fork
- run-on-tokio-explicit
- run-on-tokio-implicit
- run-on-ref-slice-fork-windows
steps:
- run: exit 0

Expand Down Expand Up @@ -164,6 +165,40 @@ jobs:
path: bins/
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}

build-binary-windows:
name: Build binary (Windows)
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
persist-credentials: false
path: 'semver'

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- uses: Swatinem/rust-cache@v2
with:
workspaces: 'semver'

- name: build and cache
run: |
cd semver
cargo build
mkdir ..\bins
mv target\debug\cargo-semver-checks.exe ..\bins\cargo-semver-checks.exe
- name: cache binary
uses: actions/cache/save@v3
with:
path: bins\
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}

run-on-rust-libp2p:
# Run cargo-semver-checks on a crate with no semver violations,
# to make sure there are no false-positives.
Expand Down Expand Up @@ -1125,6 +1160,103 @@ jobs:
key: ${{ runner.os }}-${{ hashFiles('.rustc-version', 'semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc
path: subject/target/semver-checks/cache

run-on-ref-slice-fork-windows:
# Same as above, but run on a Windows machine.
# This broke in a workflow of the GitHub Action using a precompiled binary
# after a fresh Rust installation, when the registry index does not exist yet
# (see https://github.com/frewsxcv/rust-crates-index/issues/97).
name: 'Semver: ref-slice fork (Windows)'
runs-on: windows-latest
needs:
- build-binary-windows
steps:
- name: Checkout cargo-semver-checks
uses: actions/checkout@v3
with:
persist-credentials: true
path: semver

- name: Checkout ref-slice fork semver break
uses: actions/checkout@v3
with:
persist-credentials: false
repository: 'mgr0dzicki/cargo-semver-action-ref-slice'
ref: 'major_change'
path: 'subject'

- name: Install rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true

- name: Restore binary
id: cache-binary
uses: actions/cache/restore@v3
with:
path: bins\
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
fail-on-cache-miss: true

- run: |
rustc --version | tee .rustc-version
- name: Restore rustdoc
id: cache
uses: actions/cache/restore@v3
with:
key: ${{ runner.os }}-${{ hashFiles('.rustc-version', 'semver\**\Cargo.lock') }}-${{ github.job }}-rustdoc
path: subject\target\semver-checks\cache

- name: Restore cargo index and rustdoc target dir
uses: Swatinem/rust-cache@v2
with:
workspaces: |
subject\target\semver-checks\local-ref_slice-1_2_2\
- name: Run cargo-semver-checks
continue-on-error: true
id: semver_checks
run: |
cd semver
..\bins\cargo-semver-checks.exe semver-checks check-release --manifest-path="..\subject\Cargo.toml" 2>&1 | tee output
- name: Check whether it failed
if: steps.semver_checks.outcome != 'failure'
run: |
echo "Error! check-release should have failed because of the breaking change, but it has not."
exit 1
- name: Baseline is correct
run: |
cd semver
$EXPECTED = " Checking ref_slice v1.2.1 -> v1.2.2 (patch change)"
# Strip ANSI escapes for colors and bold text before comparing.
$RESULT = (cat output | grep 'ref_slice v1.' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g") | Out-String
compare $RESULT $EXPECTED
- name: Semver break found
run: |
cd semver
$EXPECTED = "--- failure function_missing: pub fn removed or renamed ---"
$RESULT = (cat output | grep failure)
compare $RESULT $EXPECTED
# Ensure the following fragment (not full line!) is in the output file:
grep ' function ref_slice::ref_slice, previously in file' output
- name: Cleanup
run: |
cd semver
rm output
- name: Save rustdoc
uses: actions/cache/save@v3
if: steps.cache.outputs.cache-hit != 'true'
with:
key: ${{ runner.os }}-${{ hashFiles('.rustc-version', 'semver\**\Cargo.lock') }}-${{ github.job }}-rustdoc
path: subject\target\semver-checks\cache

init-release:
name: Run the release workflow
needs:
Expand Down
46 changes: 6 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ignore = "0.4.18"
clap-verbosity-flag = "2.0.0"
log = "0.4.17"
git2 = { version = "0.16.0", default-features = false }
crates-index = { version = "0.19.2" }
crates-index = { version = "0.19.6" }
human-panic = "1.0.3"
bugreport = "0.5.0"
itertools = "0.10.5"
Expand Down

0 comments on commit 37568fc

Please sign in to comment.