Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Update README.md

Update README.md #9013

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- "staging"
- "master"
env:
CARGO_INCREMENTAL: 0
CARGO_TERM_COLOR: always
jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dprint/check@v2.1
# job to run change detection
changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
electron: ${{ steps.filter.outputs.electron }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
backend:
- 'crates/**'
- 'Cargo.toml'
- 'Cargo.lock'
frontend:
- 'taker-frontend/**'
- 'maker-frontend/**'
electron:
- 'crates/taker-electron/**'
gather_workspace_members:
runs-on: ubuntu-latest
outputs:
members: ${{ steps.cargo-metadata.outputs.members }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- id: cargo-metadata
run: |
# replacing itchysats with taker-electron: dirty fix, as neon and electron require the package name for processing. neon requires the package name to equal the crate name -
# and electron uses the package name as name of the application.
WORKSPACE_MEMBERS=$(cargo metadata --format-version=1 --no-deps | jq -c '.packages |.[] | select(.name == "itchysats").name |= "taker-electron" | .name' | jq -s | jq -c '.')
echo "::set-output name=members::${WORKSPACE_MEMBERS}"
clippy:
needs: [gather_workspace_members, changes]
if: ${{ needs.changes.outputs.backend == 'true' }}
strategy:
matrix:
crate: ${{ fromJson(needs.gather_workspace_members.outputs.members) }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/${{ matrix.crate }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2.0.1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo clippy --all-targets -- -D warnings
lint-commits:
runs-on: ubuntu-latest
if: github.event.ref != 'refs/heads/master'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get all commits on current master
run: git fetch origin master
- name: Log all commits we will analyze
run: git log --pretty=format:%s origin/master..HEAD
- name: Disallow fixup! commits
run: git log --pretty=format:%s origin/master..HEAD | grep -zv fixup!
- name: Disallow squash! commits
run: git log --pretty=format:%s origin/master..HEAD | grep -zv squash!
frontend:
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
strategy:
matrix:
bin: [maker, taker]
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ matrix.bin }}-frontend
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: "yarn"
cache-dependency-path: ${{ matrix.bin }}-frontend/yarn.lock
- run: yarn install
- run: yarn run eslint
- run: yarn run tsc
- run: yarn run test
- run: yarn run build
electron:
needs: changes
if: ${{ needs.changes.outputs.electron == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: crates/taker-electron
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
cache: "yarn"
cache-dependency-path: crates/taker-electron/yarn.lock
- name: Install Protoc
uses: arduino/setup-protoc@v1
- run: yarn install
- run: yarn run eslint
- run: yarn run tsc
- run: yarn run build:rust
- run: yarn run build:main
- run: yarn run build:renderer
# Builds and archives the test so that they can be run later in multiple jobs
build-tests:
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
strategy:
matrix:
os: [ubuntu-latest, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2.0.1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Build and archive tests
run: cargo nextest archive --archive-file nextest-archive.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v3
with:
name: nextest-archive-${{ matrix.os }}
path: nextest-archive.tar.zst
# Run partitioned tests
# In order to change the number of jobs, amend `partition` array and `--partition count` argument
run-tests:
strategy:
matrix:
partition: [1, 2, 3, 4]
os: [ubuntu-latest, macos-12]
needs: [build-tests, changes]
if: ${{ needs.changes.outputs.backend == 'true' }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
# In this example, the Rust toolchain is not installed. cargo nextest's run phase does not
# require Cargo. You can choose to install Rust if your tests require it, of course.
# Instead, create ~/.cargo/bin as required by the install action.
- run: mkdir -p ~/.cargo/bin
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Download archive
uses: actions/download-artifact@v3
with:
name: nextest-archive-${{ matrix.os }}
- name: Run tests
run: |
~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst \
--profile ci \
--partition count:${{ matrix.partition }}/4
smoke_test:
needs: changes
if: ${{ (needs.changes.outputs.backend || needs.changes.outputs.frontend) == 'true' }}
strategy:
matrix:
os: [ubuntu-latest, macos-12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2.0.1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- run: cargo build --bin maker --bin taker
- name: Smoke testing maker for ${{ matrix.os }} binary
shell: bash
run: |
cargo dev-maker-headless &
n=0
until [ "$n" -ge 3 ]
do
n=$((n+1))
sleep 10
curl --fail http://localhost:8001/api/alive && break;
done
- name: Smoke testing taker for ${{ matrix.os }} binary
shell: bash
run: |
cargo dev-taker-headless &
n=0
until [ "$n" -ge 3 ]
do
n=$((n+1))
sleep 10
curl --fail http://localhost:8000/api/alive && break;
done
daemons_arm_build:
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2.0.1
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Install compiler for aarch64 arch
run: |
sudo apt-get update
sudo apt-get install gcc-aarch64-linux-gnu
sudo apt-get install g++-aarch64-linux-gnu
- run: cargo build --target=aarch64-unknown-linux-gnu --bins
sqlx-db-check:
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' }}
steps:
- uses: actions/checkout@v3
- name: Setup rust toolchain
run: rustup show
- uses: Swatinem/rust-cache@v2.0.1
- name: Install sqlx-cli
# Lock sqlx-cli version to the same version as sqlx in the workspace
run: |
cargo install sqlx-cli@0.6.2
- name: Run sqlx prepare
run: |
cd crates/sqlite-db
./prepare_db.sh
git diff --exit-code sqlx-data.json
- name: sqlx prepare was not run
if: failure()
run: |
echo "sqlx prepare was not run or sqlx-data.json was not checked-in"
# We need some "accummulation" job here because bors fails (timeouts) to
# listen on matrix builds. Bors will only listen on this job.
ci-success:
name: CI
needs:
- changes
- gather_workspace_members
- formatting
- lint-commits
- build-tests
- run-tests
- sqlx-db-check
- frontend
- electron
- smoke_test
- daemons_arm_build
- clippy
runs-on: ubuntu-latest
if: ${{ always() && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) }}
steps:
- name: CI succeeded
run: exit 0