separate cargo clippy and cargo fmt steps in ci #1547
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 | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
build-cli: | |
name: Build compiler | |
strategy: | |
matrix: | |
target: | |
- target: aarch64-unknown-linux-musl | |
os: ubuntu-latest | |
build-name: isograph_cli | |
artifact-name: isograph_cli-bin-linux-arm64 | |
cross: true | |
- target: x86_64-apple-darwin | |
os: macos-latest | |
build-name: isograph_cli | |
artifact-name: isograph_cli-macos-x64 | |
- target: aarch64-apple-darwin | |
os: macos-latest | |
build-name: isograph_cli | |
artifact-name: isograph_cli-macos-arm64 | |
- target: x86_64-pc-windows-msvc | |
os: windows-latest | |
longpaths: true | |
build-name: isograph_cli.exe | |
artifact-name: isograph_cli-bin-win-x64 | |
uses: ./.github/workflows/build-cli.yml | |
with: | |
target: ${{ matrix.target.target }} | |
os: ${{ matrix.target.os }} | |
build-name: ${{ matrix.target.build-name }} | |
artifact-name: ${{ matrix.target.artifact-name }} | |
longpaths: ${{ matrix.target.longpaths || false }} | |
cross: ${{ matrix.target.cross || false }} | |
build-cli-linux: | |
name: Build compiler (x86_64-unknown-linux-musl) | |
uses: ./.github/workflows/build-cli.yml | |
with: | |
target: x86_64-unknown-linux-musl | |
os: ubuntu-latest | |
build-name: isograph_cli | |
artifact-name: isograph_cli-linux-x64 | |
build-demos: | |
name: Build demos | |
runs-on: ubuntu-latest | |
needs: [build-cli-linux] | |
strategy: | |
matrix: | |
target: | |
- folder: github-demo | |
- folder: pet-demo | |
- folder: vite-demo | |
steps: | |
- uses: actions/checkout@v2 | |
- name: 'Download cli binary' | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-linux-x64 | |
path: artifacts/linux-x64 | |
- name: Make artifact executable | |
run: chmod +x ./artifacts/linux-x64/isograph_cli | |
- name: 'Build project' | |
run: ./artifacts/linux-x64/isograph_cli --config ./demos/${{ matrix.target.folder }}/isograph.config.json | |
- name: 'Check working directory status' | |
run: './scripts/check-git-status.sh' | |
build-json-schema: | |
name: Build json schema | |
uses: ./.github/workflows/run-cargo-bin-and-ensure-no-changes.yml | |
with: | |
binary: build_json_schema | |
typecheck-demos: | |
name: Typecheck and Lint Demos | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
target: | |
- folder: github-demo | |
- folder: pet-demo | |
- folder: vite-demo | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v2 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
# TODO reuse some artifacts or something, we're doing this in multiple steps | |
- name: Build JS files | |
run: pnpm -r compile | |
- name: Typecheck | |
run: cd ./demos/${{ matrix.target.folder }} && pnpm tsc | |
- name: Lint | |
run: cd ./demos/${{ matrix.target.folder }} && pnpm lint | |
build-js-packages: | |
name: Build js packages | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v2 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Build | |
run: pnpm -r compile | |
- name: Run unit tests | |
# Note: unit tests have to run after building, because the unit tests | |
# rely on Isograph, which relies on @isograph/react being a valid input | |
# | |
# This can be overcome, if necessary, e.g. if "@isograph/react" was a | |
# parameter passed to the CLI. | |
run: pnpm test | |
build-website: | |
name: Build website | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./docs-website | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Build website | |
run: pnpm build | |
- name: Upload artifact | |
id: upload-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docusaurus-build | |
# upload-artifact ignores working-directory, seemingly, though | |
# the docs indicate otherwise. | |
path: docs-website/build/ | |
retention-days: 1 | |
if-no-files-found: error | |
prettier: | |
name: Run prettier | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Run prettier | |
run: pnpm run format-prettier | |
- name: 'Check working directory status' | |
run: './scripts/check-git-status.sh' | |
cargo-fmt: | |
name: cargo fmt | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Run cargo fmt | |
run: cargo fmt | |
- name: 'Check working directory status' | |
run: './scripts/check-git-status.sh' | |
cargo-clippy: | |
name: cargo clippy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Run cargo clippy | |
run: cargo clippy | |
cargo-test: | |
name: Run cargo test (excluding relay tests) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: stable | |
components: rustfmt | |
- name: Run cargo test | |
run: cargo test | |
build-fixtures: | |
name: Build fixtures | |
uses: ./.github/workflows/run-cargo-bin-and-ensure-no-changes.yml | |
with: | |
binary: generate_isograph_fixtures | |
all-checks-passed: | |
name: All checks passed | |
runs-on: ubuntu-latest | |
needs: | |
[ | |
build-fixtures, | |
build-js-packages, | |
build-cli, | |
build-cli-linux, | |
build-json-schema, | |
build-demos, | |
build-website, | |
prettier, | |
cargo-fmt, | |
cargo-clippy, | |
cargo-test, | |
typecheck-demos, | |
] | |
steps: | |
- name: Do nothing | |
run: echo Isograph is awesome! | |
deploy-website: | |
name: Deploy website | |
runs-on: ubuntu-latest | |
needs: [all-checks-passed] | |
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
defaults: | |
run: | |
working-directory: ./docs-website | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
- name: Use Node.js 22 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'pnpm' | |
- name: 'Download build folder' | |
uses: actions/download-artifact@v4 | |
with: | |
name: docusaurus-build | |
path: docs-website/build | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload custom | |
run: tar --dereference --hard-dereference --directory "build" -cvf "$RUNNER_TEMP/artifact.tar" --exclude=.git --exclude =.github . | |
- name: Upload artifact | |
id: upload-artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: github-pages | |
path: ${{ runner.temp }}/artifact.tar | |
retention-days: 1 | |
if-no-files-found: error | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
main-release: | |
name: Release packages to NPM | |
runs-on: macos-latest | |
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref == 'refs/heads/main' || github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
needs: [all-checks-passed] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 22 | |
registry-url: https://registry.npmjs.org/ | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
- name: Change package versions to commit | |
run: pnpm gulp setMainVersion | |
env: | |
RELEASE_COMMIT_SHA: ${{ github.sha }} | |
# TODO reuse this somehow? | |
- name: Build | |
run: pnpm -r compile | |
- name: Download artifact isograph_cli-linux-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-linux-x64 | |
path: libs/isograph-compiler/artifacts/linux-x64 | |
- name: Download artifact isograph_cli-bin-linux-arm64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-bin-linux-arm64 | |
path: libs/isograph-compiler/artifacts/linux-arm64 | |
- name: Download artifact isograph_cli-macos-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-macos-x64 | |
path: libs/isograph-compiler/artifacts/macos-x64 | |
- name: Download artifact isograph_cli-macos-arm64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-macos-arm64 | |
path: libs/isograph-compiler/artifacts/macos-arm64 | |
- name: Download artifact isograph_cli-bin-win-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-bin-win-x64 | |
path: libs/isograph-compiler/artifacts/win-x64 | |
- name: Mark binaries as executable | |
run: | | |
chmod +x libs/isograph-compiler/artifacts/linux-x64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/linux-arm64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/macos-x64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/macos-arm64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/win-x64/isograph_cli.exe | |
- name: Publish to NPM | |
run: | | |
for pkg in libs/*; do | |
echo PUBLISHING $pkg | |
cd $pkg | |
npm publish --tag main | |
cd ../.. | |
done | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} | |
versioned-release: | |
name: Release packages to NPM (latest) | |
runs-on: macos-latest | |
if: github.event_name == 'push' && github.repository == 'isographlabs/isograph' && github.ref_type == 'tag' && startsWith(github.ref_name, 'v') | |
needs: [all-checks-passed] | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: pnpm/action-setup@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 22 | |
registry-url: https://registry.npmjs.org/ | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile --ignore-scripts | |
# - name: Change package versions to commit | |
# run: pnpm gulp setMainVersion | |
# # TODO do this less hackily | |
- name: Build | |
run: pnpm -r compile | |
- name: Download artifact isograph_cli-linux-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-linux-x64 | |
path: libs/isograph-compiler/artifacts/linux-x64 | |
- name: Download artifact isograph_cli-bin-linux-arm64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-bin-linux-arm64 | |
path: libs/isograph-compiler/artifacts/linux-arm64 | |
- name: Download artifact isograph_cli-macos-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-macos-x64 | |
path: libs/isograph-compiler/artifacts/macos-x64 | |
- name: Download artifact isograph_cli-macos-arm64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-macos-arm64 | |
path: libs/isograph-compiler/artifacts/macos-arm64 | |
- name: Download artifact isograph_cli-bin-win-x64 | |
uses: actions/download-artifact@v4 | |
with: | |
name: isograph_cli-bin-win-x64 | |
path: libs/isograph-compiler/artifacts/win-x64 | |
- name: Mark binaries as executable | |
run: | | |
chmod +x libs/isograph-compiler/artifacts/linux-x64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/linux-arm64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/macos-x64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/macos-arm64/isograph_cli | |
chmod +x libs/isograph-compiler/artifacts/win-x64/isograph_cli.exe | |
- name: Publish latest version to NPM | |
run: | | |
for pkg in libs/*; do | |
echo PUBLISHING $pkg | |
cd $pkg | |
npm publish --tag latest | |
cd ../.. | |
done | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |