Merge pull request #1273 from SierraSoftworks/dependabot/cargo/serde-… #2305
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test Changes | |
on: | |
push: | |
paths-ignore: | |
- "README.md" | |
jobs: | |
code-quality: | |
name: Code Quality | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: cache ~/.cargo | |
uses: Swatinem/rust-cache@v2 | |
- name: rustup install | |
uses: actions-rs/toolchain@v1.0.7 | |
with: | |
toolchain: stable | |
components: clippy, rustfmt | |
override: true | |
- name: install protoc | |
run: | | |
Invoke-WebRequest -OutFile /tmp/protoc.zip -Uri https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-linux-x86_64.zip | |
Expand-Archive /tmp/protoc.zip -DestinationPath ../tools | |
Add-Content -Path $env:GITHUB_PATH -Value "$((get-item ./).parent.fullname)/tools/bin" | |
Get-Content $env:GITHUB_PATH | |
shell: pwsh | |
- name: cargo clippy | |
uses: actions-rs/cargo@v1.0.3 | |
with: | |
command: clippy | |
args: --all-targets --all-features | |
- name: cargo fmt --check | |
uses: actions-rs/cargo@v1.0.3 | |
with: | |
command: fmt | |
args: --check --all | |
test-platforms: | |
name: ${{ matrix.os }}-${{ matrix.arch }}-test | |
runs-on: ${{ matrix.run_on }} | |
continue-on-error: ${{ matrix.experimental || false }} | |
permissions: | |
id-token: write | |
contents: read | |
strategy: | |
matrix: | |
include: | |
- arch: amd64 | |
os: windows | |
run_on: windows-latest | |
target: x86_64-pc-windows-msvc | |
extension: .exe | |
- arch: amd64 | |
run_on: ubuntu-latest | |
os: linux | |
target: x86_64-unknown-linux-gnu | |
coverage: true | |
setup: | | |
sudo apt-get update | |
sudo apt-get install -y libdbus-1-3 libdbus-1-dev | |
# - arch: "386" | |
# os: linux | |
# run_on: ubuntu-20.04 | |
# target: i686-unknown-linux-gnu | |
# experimental: true | |
# skiptests: true | |
# setup: | | |
# sudo apt-get update | |
# sudo apt-get install -y libdbus-1-3 libdbus-1-dev | |
- arch: "arm64" | |
os: linux | |
run_on: ubuntu-latest | |
target: aarch64-unknown-linux-gnu | |
experimental: true | |
skiptests: true | |
setup: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-aarch64-linux-gnu lld | |
# Ensure that the libgcc library can be found | |
sudo ln -s /usr/aarch64-linux-gnu/lib/libgcc_s.so.1 /usr/aarch64-linux-gnu/lib/libgcc_s.so | |
flags: --no-default-features | |
- arch: amd64 | |
run_on: macos-latest | |
os: darwin | |
target: x86_64-apple-darwin | |
- arch: arm64 | |
run_on: macos-latest | |
os: darwin | |
target: aarch64-apple-darwin | |
experimental: true | |
skiptests: true | |
steps: | |
- name: setup dependencies | |
run: ${{ matrix.setup }} | |
if: matrix.setup | |
- uses: actions/checkout@v4 | |
- name: rustup install nightly | |
uses: actions-rs/toolchain@v1.0.7 | |
with: | |
toolchain: stable | |
profile: minimal | |
target: ${{ matrix.target }} | |
override: true | |
components: llvm-tools-preview | |
- name: cache ~/.cargo | |
uses: Swatinem/rust-cache@v2 | |
- name: install protoc | |
run: | | |
if ('${{ matrix.os }}' -eq 'windows') { | |
$protoc_arch = 'win64' | |
} elseif ('${{ matrix.os }}' -eq 'darwin') { | |
$protoc_arch = 'osx-x86_64' | |
} else { | |
$protoc_arch = 'linux-x86_64' | |
} | |
$protoc_url = "https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-$protoc_arch.zip" | |
Write-Host "Downloading protoc from '$protoc_url'" | |
Invoke-WebRequest -OutFile protoc.zip -Uri $protoc_url | |
Expand-Archive protoc.zip -DestinationPath ../tools | |
Add-Content -Path $env:GITHUB_PATH -Value "$((Get-Item ./).Parent.FullName)/tools/bin" | |
shell: pwsh | |
- name: git config | |
run: | | |
git config --global init.defaultBranch "main" | |
- name: cargo build | |
uses: actions-rs/cargo@v1.0.3 | |
if: matrix.skiptests | |
with: | |
command: build | |
args: --target ${{ matrix.target }} ${{ matrix.flags }} | |
- name: cargo test | |
uses: actions-rs/cargo@v1.0.3 | |
if: "!matrix.skiptests" | |
with: | |
command: test | |
args: --no-fail-fast --target ${{ matrix.target }} ${{ matrix.flags }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RUSTFLAGS: "-C instrument_coverage" | |
LLVM_PROFILE_FILE: default.profraw | |
- name: install rustfilt | |
uses: actions-rs/cargo@v1.0.3 | |
if: matrix.coverage || false | |
with: | |
command: install | |
args: rustfilt | |
- name: prepare coverage output | |
if: matrix.coverage || false | |
shell: pwsh | |
run: | | |
Write-Host "Merging raw profile output files" | |
&"$(rustc --print target-libdir)/../bin/llvm-profdata" merge -sparse default.profraw -o default.profdata | |
$latest_asset = Get-ChildItem -Path ./target/${{ matrix.target }}/debug/deps -Filter "git_tool-*" -File ` | |
| Where-Object { $_.Name.EndsWith(".exe") -or (-not $_.Name.Contains(".")) } ` | |
| Sort-Object -Top 1 -Property LastWriteTime | |
Write-Host "Latest Asset: $latest_asset" | |
Write-Host "Exporting LCOV coverage report" | |
&"$(rustc --print target-libdir)/../bin/llvm-cov" export -instr-profile default.profdata $latest_asset ` | |
-Xdemangler=rustfilt ` | |
-ignore-filename-regex='.cargo|rustc' ` | |
-compilation-dir=src ` | |
-format=lcov > lcov.info | |
- name: get secrets - codecov | |
uses: hashicorp/vault-action@v3.0.0 | |
if: matrix.coverage || false | |
with: | |
url: https://vault.sierrasoftworks.com | |
method: jwt | |
path: github-actions | |
role: pull_request | |
jwtGithubAudience: https://vault.sierrasoftworks.com | |
secrets: | | |
secrets/data/repos/SierraSoftworks/git-tool/public/codecov token | CODECOV_TOKEN; | |
- name: codecov upload | |
uses: codecov/codecov-action@v4 | |
if: matrix.coverage || false | |
with: | |
token: ${{ env.CODECOV_TOKEN }} | |
# - uses: anchore/sbom-action@v0 | |
# with: | |
# file: "target/${{ matrix.target }}/debug/git-tool${{ matrix.extension }}" | |
# format: 'spdx-json' | |
# output-file: 'sbom.spdx.json' | |
# upload-artifact: false | |
test-done: | |
name: Tests Complete | |
needs: | |
- test-platforms | |
- code-quality | |
runs-on: ubuntu-20.04 | |
steps: | |
- run: echo "Tests Complete for All Platforms" |