Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for precompiled binary failing on Windows to CI #389

Merged
merged 8 commits into from
Feb 25, 2023
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved

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: Run cargo-semver-checks on 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/
obi1kenobi marked this conversation as resolved.
Show resolved Hide resolved
mgr0dzicki marked this conversation as resolved.
Show resolved Hide resolved

- 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