Continuous Integration #74
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: Continuous Integration | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
DEFAULT_CRATE_NAME: wit_language_server | |
RUST_BACKTRACE: 1 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
rust: | |
name: Compile and Test (${{ matrix.os }}) | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
runs-on: ${{ matrix.os }} | |
steps: | |
# This is a workaround for https://github.com/actions/checkout/issues/135 | |
- name: Set git to use LF | |
run: | | |
git config --global core.autocrlf false | |
git config --global core.eol lf | |
- uses: actions/checkout@v2 | |
- name: Setup Rust | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Install Nextest | |
uses: taiki-e/install-action@nextest | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Type Checking | |
run: cargo check --workspace --verbose --locked | |
- name: Build | |
run: cargo build --workspace --verbose --locked | |
- name: Test | |
run: cargo nextest run --workspace --verbose --locked | |
- name: Doc Tests | |
run: cargo test --doc --workspace --verbose --locked | |
parser: | |
name: Parser Tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: tree-sitter-wit | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Rust | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Install Tree Sitter CLI | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: tree-sitter-cli | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Ensure up to date | |
run: | | |
tree-sitter generate | |
git status --porcelain | |
if [[ -n $(git status --porcelain) ]]; then | |
echo "[ERROR] The tree sitter grammar needs to be re-generated" | |
exit 1 | |
fi | |
- name: Test | |
run: tree-sitter test | |
lints: | |
name: Linting and Formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup Rust | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Check Formatting | |
run: cargo fmt --all --verbose --check | |
- name: Clippy | |
run: cargo clippy --workspace --verbose --locked | |
vscode: | |
name: VS Code Plugin | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup Rust | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: latest | |
cache: npm | |
cache-dependency-path: plugins/vscode/package-lock.json | |
- name: Compile the language server | |
run: cargo build -p wit-language-server | |
- name: Install JavaScript dependencies | |
run: npm ci | |
working-directory: plugins/vscode | |
- name: Build | |
run: npm run compile | |
working-directory: plugins/vscode | |
api-docs: | |
name: Publish API Docs to GitHub Pages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Rust Cache | |
uses: taiki-e/install-action@nextest | |
- name: Install llvm-cov | |
uses: taiki-e/install-action@cargo-llvm-cov | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup Rust | |
uses: dsherret/rust-toolchain-file@v1 | |
- name: Generate API Docs | |
run: cargo doc --workspace --verbose --locked | |
- name: Generate Code Coverage | |
run: cargo llvm-cov nextest --html --workspace --no-fail-fast --show-instantiations | |
- name: Set up Pages Directory | |
run: | | |
mkdir -p pages | |
cp -r target/doc pages/crate-docs | |
cp -r target/llvm-cov/html pages/coverage | |
- name: Set up redirects | |
run: | | |
echo '<meta http-equiv="refresh" content="0; url=crate-docs/index.html" />' > pages/index.html | |
echo '<meta http-equiv="refresh" content="0; url=${{ env.DEFAULT_CRATE_NAME }}/index.html" />' > pages/crate-docs/index.html | |
- name: Upload API Docs | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: github.ref == 'refs/heads/main' | |
with: | |
branch: gh-pages | |
folder: pages | |
single-commit: true | |
workflow-times: | |
name: Workflow Timings | |
runs-on: ubuntu-latest | |
needs: | |
- rust | |
- parser | |
- vscode | |
steps: | |
- name: Time Reporter | |
uses: Michael-F-Bryan/[email protected] | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | | |
Compile and Test (ubuntu-latest) | |
Compile and Test (macos-latest) | |
Compile and Test (windows-latest) | |
VS Code Plugin | |
Parser Tests | |
message: | | |
Make sure you keep an eye on build times! | |
The goal is to keep CI times under 5 minutes so developers can maintain a fast edit-compile-test cycle. | |