Fix links to competitors in the docs (#114) #374
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: CI + CD | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
# Make sure CI fails on all warnings, including Clippy lints | |
env: | |
RUSTFLAGS: "-Dwarnings" | |
jobs: | |
lint: # Also checks formatting. | |
name: Run lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cargo | |
rust_components: clippy, rustfmt | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/pre-commit | |
key: | |
${{ runner.os }}-pre-commit-${{ | |
hashFiles('**/.pre-commit-config.yaml') }} | |
- name: Run lint | |
run: | | |
just pre-commit | |
just lint | |
unit: | |
name: Run unit test | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cargo | |
- name: Run unit test | |
run: just test | |
build: | |
name: Build release | |
needs: | |
- lint | |
- unit | |
strategy: | |
matrix: | |
build: | |
- linux | |
- macos | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
- build: macos | |
os: macos-latest | |
target: x86_64-apple-darwin | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: cross | |
rust_target: ${{ matrix.target }} | |
- name: Build release | |
run: | | |
just get-cross | |
just cross ${{ matrix.target }} | |
- name: Upload binary artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: pls-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/pls | |
docs: | |
name: Publish docs | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup env | |
uses: ./.github/actions/setup-env | |
with: | |
rust_cache_key: docs | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: pls-x86_64-unknown-linux-musl | |
path: /tmp/pls | |
- name: Make binary accessible and executable | |
run: | | |
chmod +x /tmp/pls/pls | |
echo "/tmp/pls" >> $GITHUB_PATH | |
# This must be a separate step because `$PATH` changes are not reflected | |
# immediately. | |
- name: Ensure binary is accessible | |
run: pls --version | |
- name: Setup PDM | |
uses: pdm-project/setup-pdm@v4 | |
with: | |
cache: true | |
python-version-file: examples/pyproject.toml | |
cache-dependency-path: examples/pdm.lock | |
- name: Enable Corepack | |
run: corepack enable pnpm | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
cache: pnpm | |
node-version-file: docs/package.json | |
cache-dependency-path: docs/pnpm-lock.yaml | |
- name: Install all dependencies | |
run: just install | |
- name: Generate examples | |
working-directory: examples/ | |
run: just all | |
- name: Build and publish docs | |
if: github.event_name == 'push' | |
working-directory: docs/ | |
run: | | |
pnpm build | |
cd dist | |
git init --initial-branch=gh-pages | |
git config user.name "Dhruv Bhanushali" | |
git config user.email "hi@dhruvkb.dev" | |
git add . | |
git commit --message "Build documentation" | |
git remote add origin https://x-access-token:${{ secrets.ACCESS_TOKEN }}@github.com/pls-rs/pls-rs.github.io.git | |
git push --force origin gh-pages |