Refactor CI workflow

This commit is contained in:
Oliver Hamlet
2024-06-28 17:44:52 +01:00
parent 54f9541c34
commit b2fa93f134
+22 -64
View File
@@ -16,65 +16,15 @@ jobs:
cargo fmt -- --version cargo fmt -- --version
cargo fmt --all -- --check cargo fmt --all -- --check
windows: build:
runs-on: windows-2019 strategy:
steps: matrix:
- uses: actions/checkout@v4 os:
- windows-2019
- ubuntu-20.04
- uses: actions/cache@v4 runs-on: ${{ matrix.os }}
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Prepare test resources
run: |
cd tests
(New-Object Net.WebClient).DownloadFile('https://github.com/Ortham/testing-plugins/archive/1.4.0.zip', "$PWD/1.4.0.zip")
7z x 1.4.0.zip
mv testing-plugins-1.4.0 testing-plugins
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z', "$PWD/libloot_win32.7z")
7z x libloot_win32.7z
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z', "$PWD/libloot_win64.7z")
7z x libloot_win64.7z
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64
(New-Object Net.WebClient).DownloadFile('https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z', "$PWD/loot_api_python.7z")
7z x loot_api_python.7z
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
cd ..
- name: Build and run tests
run: cargo test --all --all-features
# Need to rebuild the FFI wrapper so that its binary is given a filename
# without a hash.
- name: Build FFI wrapper
run: |
cargo build --manifest-path ffi/Cargo.toml
cbindgen ffi/ -o ffi/include/loot_condition_interpreter.h
# Use bash because PowerShell doesn't fail if one command fails.
- name: Build and run C++ tests
shell: bash
run: |
mkdir ffi/build
cd ffi/build
cmake ..
cmake --build .
ctest
linux:
runs-on: ubuntu-20.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -90,43 +40,51 @@ jobs:
- name: Install cargo-llvm-cov - name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov uses: taiki-e/install-action@cargo-llvm-cov
if: runner.os == 'Linux'
- name: Prepare test resources - name: Prepare test resources
shell: bash
run: | run: |
cd tests cd tests
wget https://github.com/Ortham/testing-plugins/archive/1.4.1.tar.gz curl -sSfLO 'https://github.com/Ortham/testing-plugins/archive/1.4.0.zip'
tar -xf 1.4.1.tar.gz 7z x 1.4.0.zip
mv testing-plugins-1.4.1 testing-plugins mv testing-plugins-1.4.0 testing-plugins
wget https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z curl -sSfLO 'https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z'
7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z 7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win32.7z
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32 mv libloot-0.18.2-0-gb1a9e31_0.18.2-win32 libloot_win32
wget https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z curl -sSfLO 'https://github.com/loot/libloot/releases/download/0.18.2/libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z'
7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z 7z x libloot-0.18.2-0-gb1a9e31_0.18.2-win64.7z
mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64 mv libloot-0.18.2-0-gb1a9e31_0.18.2-win64 libloot_win64
wget https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z curl -sSfLO 'https://github.com/loot/loot-api-python/releases/download/4.0.2/loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z'
7z x loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z 7z x loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32.7z
mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python mv loot_api_python-4.0.2-0-gd356ac2_master-python2.7-win32 loot_api_python
cd .. cd ..
- name: Build and run tests
run: cargo test --workspace
if: runner.os != 'Linux'
- name: Build and run tests with code coverage - name: Build and run tests with code coverage
run: cargo llvm-cov --workspace --lcov --output-path lcov.info run: cargo llvm-cov --workspace --lcov --output-path lcov.info
if: runner.os == 'Linux'
- name: Upload code coverage to Coveralls - name: Upload code coverage to Coveralls
uses: coverallsapp/github-action@v2 uses: coverallsapp/github-action@v2
if: runner.os == 'Linux'
# Need to rebuild the FFI wrapper so that its binary is given a filename # Need to rebuild the FFI wrapper so that its binary is given a filename
# without a hash. # without a hash.
- name: Build FFI wrapper - name: Build FFI wrapper
shell: bash
run: | run: |
cargo build --manifest-path ffi/Cargo.toml cargo build --manifest-path ffi/Cargo.toml
cbindgen ffi/ -o ffi/include/loot_condition_interpreter.h cbindgen ffi/ -o ffi/include/loot_condition_interpreter.h
# Use bash because PowerShell doesn't fail if one command fails.
- name: Build and run C++ tests - name: Build and run C++ tests
shell: bash shell: bash
run: | run: |