name: CI
on:
push:
branches: [main, develop]
pull_request:
types: [opened, labeled, synchronize, reopened]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
consume-run-ci:
if: >-
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'run-ci')
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Remove one-shot CI label
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: >-
gh api --method DELETE
"repos/${{ github.repository }}/issues/${PR_NUMBER}/labels/run-ci"
frontend-invariants:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: No markup parsing or dynamic evaluation
run: |
# Strip comments first: they legitimately name these APIs when
# explaining why the code does not use them.
if sed 's://.*::' desktop/ui/js/*.js desktop/ui/js/views/*.js \
| grep -nE 'innerHTML|outerHTML|insertAdjacentHTML|document\.write|eval\(|new Function'; then
echo "::error::markup-parsing or dynamic-eval API used in desktop/ui/js"
exit 1
fi
- name: No external assets and no inline handlers
run: |
if grep -nE 'src="https?:|href="https?://[^"]*\.(js|css)|onclick=|onload=' desktop/ui/index.html; then
echo "::error::desktop/ui/index.html references an external asset or an inline handler"
exit 1
fi
test:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
save-if: ${{ github.ref == 'refs/heads/develop' }}
- name: Install Linux desktop dependencies
if: runner.os == 'Linux'
run: >-
sudo apt-get update &&
sudo apt-get install -y
libwebkit2gtk-4.1-dev
libappindicator3-dev
librsvg2-dev
patchelf
- run: cargo fmt --check
- run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- run: cargo test --workspace --all-features
- name: Audit Rust dependencies
if: runner.os == 'Linux'
uses: EmbarkStudios/cargo-deny-action@3c6349835b2b7b196a839186cb8b78e02f7b5f25 with:
command: check
- run: cargo build --release -p gitbound-desktop
format:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 - uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 - uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c with:
tool: dprint
- run: dprint check
msrv:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 with:
toolchain: "1.88"
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 - name: Install Linux desktop dependencies
run: >-
sudo apt-get update &&
sudo apt-get install -y
libwebkit2gtk-4.1-dev
libappindicator3-dev
librsvg2-dev
patchelf
- run: cargo check --workspace --all-features --all-targets
coverage:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 with:
components: llvm-tools-preview
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 - uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c with:
tool: cargo-llvm-cov
- name: Install Linux desktop dependencies
run: >-
sudo apt-get update &&
sudo apt-get install -y
libwebkit2gtk-4.1-dev
libappindicator3-dev
librsvg2-dev
patchelf
- run: cargo llvm-cov --workspace --all-features --lcov --output-path lcov.info
- name: Summarise
run: cargo llvm-cov report --summary-only >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a with:
name: coverage-lcov
path: lcov.info
if-no-files-found: error
action-lint:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Validate action.yml
run: python3 .github/scripts/check_action.py
- name: Shell-check the composite steps
run: python3 .github/scripts/shellcheck_action.py
links:
if: >-
github.event.action != 'labeled' ||
github.event.label.name == 'run-ci'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Restore the link cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 with:
path: .lycheecache
key: lychee-${{ github.sha }}
restore-keys: lychee-
- name: Check every link in the documentation
uses: lycheeverse/lychee-action@e7477775783ea5526144ba13e8db5eec57747ce8 with:
args: >-
--config lychee.toml
--cache
--no-progress
--verbose
"**/*.md"
fail: true