chorus/.github/workflows/build_and_test.yml

103 lines
3.7 KiB
YAML
Raw Normal View History

name: Build and Test
2023-04-04 16:43:53 +02:00
on:
push:
2023-09-03 20:00:45 +02:00
branches: [ "main", "dev" ]
2023-04-04 16:43:53 +02:00
pull_request:
branches: [ "main", "dev" ]
2023-04-04 16:43:53 +02:00
env:
CARGO_TERM_COLOR: always
jobs:
2023-11-19 23:15:12 +01:00
linux:
2023-04-04 16:43:53 +02:00
runs-on: ubuntu-latest
2023-08-26 15:08:47 +02:00
2023-04-04 16:43:53 +02:00
steps:
- uses: actions/checkout@v4
2023-07-14 11:58:12 +02:00
- name: Clone spacebar server
2023-04-15 17:26:44 +02:00
run: |
2023-05-13 15:49:07 +02:00
git clone https://github.com/bitfl0wer/server.git
2023-07-14 11:58:12 +02:00
- uses: actions/setup-node@v3
with:
2023-08-25 21:30:07 +02:00
node-version: 18
2023-07-14 11:58:12 +02:00
cache: 'npm'
cache-dependency-path: server/package-lock.json
2023-05-13 15:49:07 +02:00
- name: Prepare and start Spacebar server
2023-04-15 17:26:44 +02:00
run: |
2023-04-15 17:44:58 +02:00
npm install
npm run setup
2023-04-15 17:26:44 +02:00
npm run start &
2023-05-13 15:49:07 +02:00
working-directory: ./server
2023-07-14 11:58:12 +02:00
- uses: Swatinem/rust-cache@v2
2023-08-26 13:32:35 +02:00
with:
cache-all-crates: "true"
2023-11-19 23:15:12 +01:00
prefix-key: "linux"
- name: Build, Test and Publish Coverage
run: |
2023-08-26 18:02:21 +02:00
if [ -n "${{ secrets.COVERALLS_REPO_TOKEN }}" ]; then
2023-11-20 12:38:39 +01:00
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
2023-08-26 18:02:21 +02:00
cargo binstall --no-confirm cargo-tarpaulin --force
2023-11-20 13:16:49 +01:00
cargo tarpaulin --all-features --avoid-cfg-tarpaulin --tests --verbose --skip-clean --timeout 120 --output-dir ./cargo/output-linux.lcov --out Lcov
2023-08-26 18:02:21 +02:00
else
echo "Code Coverage step is skipped on forks!"
cargo build --verbose --all-features
cargo test --verbose --all-features
fi
2023-11-20 13:16:49 +01:00
- name: Upload coverage for Linux
if: ${{ secrets.COVERALLS_REPO_TOKEN }}
uses: actions/upload-artifact@v2
with:
name: coverage-linux
path: ./cargo/output-linux.lcov
2023-11-19 23:15:12 +01:00
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Clone spacebar server
run: |
git clone https://github.com/bitfl0wer/server.git
- uses: actions/setup-node@v3
with:
node-version: 18
cache: 'npm'
cache-dependency-path: server/package-lock.json
- name: Prepare and start Spacebar server
run: |
npm install
npm run setup
npm run start &
working-directory: ./server
- uses: Swatinem/rust-cache@v2
with:
cache-all-crates: "true"
prefix-key: "macos"
2023-11-20 12:51:55 +01:00
- name: Run WASM tests with Safari, Firefox, Chrome
2023-11-19 23:18:58 +01:00
run: |
rustup target add wasm32-unknown-unknown
2023-11-20 11:43:08 +01:00
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
2023-11-20 11:46:10 +01:00
cargo binstall --no-confirm wasm-bindgen-cli --version "0.2.88" --force
2023-11-20 13:16:49 +01:00
if [ -n "${{ secrets.COVERALLS_REPO_TOKEN }}" ]; then
cargo binstall --no-confirm cargo-tarpaulin --force
SAFARIDRIVER=$(which safaridriver) CHROMEDRIVER=$(which chromedriver) GECKODRIVER=$(which geckodriver) cargo tarpaulin --target wasm32-unknown-unknown --no-default-features --features="client, rt" --avoid-cfg-tarpaulin --tests --verbose --skip-clean --timeout 120 --output-dir ./cargo/output-macos.lcov --out Lcov
else
echo "Code Coverage step is skipped on forks!"
SAFARIDRIVER=$(which safaridriver) CHROMEDRIVER=$(which chromedriver) GECKODRIVER=$(which geckodriver) cargo test --target wasm32-unknown-unknown --no-default-features --features="client, rt"
fi
- name: Upload coverage for macOS
if: ${{ secrets.COVERALLS_REPO_TOKEN }}
uses: actions/upload-artifact@v2
with:
name: coverage-macos
path: ./cargo/output-macos.lcov
upload-coverage:
needs: [linux, macos]
if: ${{ secrets.COVERALLS_REPO_TOKEN }}
runs-on: ubuntu-latest
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v2
- name: Upload coverage to Coveralls.io
uses: coverallsapp/github-action@v2