name: Static Analysis on: pull_request: push: branches: - main concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} cancel-in-progress: true permissions: contents: write pull-requests: write actions: read jobs: yarn-fmt-check: runs-on: 'ubuntu-22.04' steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - run: yarn fmt-check yarn-build-wasm: # Build the wasm blob once on the fastest runner. runs-on: runs-on=${{ github.run_id }}/family=i7ie.2xlarge/image=ubuntu22-full-x64 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - name: Install dependencies run: yarn install - name: Use correct Rust toolchain shell: bash run: | [ -e rust-toolchain.toml ] || cp rust/rust-toolchain.toml ./ - name: Install rust uses: actions-rust-lang/setup-rust-toolchain@v1 with: cache: false # Configured below. - uses: taiki-e/install-action@37bdc826eaedac215f638a96472df572feab0f9b with: tool: wasm-pack - name: Rust Cache uses: Swatinem/rust-cache@v2 with: workspaces: './rust' - name: Build Wasm shell: bash run: yarn build:wasm - uses: actions/upload-artifact@v4 with: name: prepared-wasm path: | rust/kcl-wasm-lib/pkg/kcl_wasm_lib* - uses: actions/upload-artifact@v4 with: name: prepared-ts-rs-bindings path: | rust/kcl-lib/bindings/* yarn-tsc: runs-on: ubuntu-latest needs: yarn-build-wasm steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - name: Download all artifacts uses: actions/download-artifact@v4 - name: Copy prepared wasm run: | ls -R prepared-wasm cp prepared-wasm/kcl_wasm_lib_bg.wasm public mkdir rust/kcl-wasm-lib/pkg cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg - name: Copy prepared ts-rs bindings run: | ls -R prepared-ts-rs-bindings mkdir rust/kcl-lib/bindings cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/ - run: yarn tsc yarn-lint: runs-on: ubuntu-latest needs: yarn-build-wasm steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - name: Download all artifacts uses: actions/download-artifact@v4 - name: Copy prepared wasm run: | ls -R prepared-wasm cp prepared-wasm/kcl_wasm_lib_bg.wasm public mkdir rust/kcl-wasm-lib/pkg cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg - name: Copy prepared ts-rs bindings run: | ls -R prepared-ts-rs-bindings mkdir rust/kcl-lib/bindings cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/ - run: yarn lint yarn-circular-dependencies: runs-on: ubuntu-latest needs: yarn-build-wasm steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - name: Download all artifacts uses: actions/download-artifact@v4 - name: Copy prepared wasm run: | ls -R prepared-wasm cp prepared-wasm/kcl_wasm_lib_bg.wasm public mkdir rust/kcl-wasm-lib/pkg cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg - name: Copy prepared ts-rs bindings run: | ls -R prepared-ts-rs-bindings mkdir rust/kcl-lib/bindings cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/ - run: yarn circular-deps:diff python-codespell: runs-on: ubuntu-22.04 steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 - name: Install codespell run: | python -m pip install codespell - name: Run codespell run: codespell --config .codespellrc # Edit this file to tweak the typo list and other configuration. yarn-unit-test-kcl-samples: runs-on: ubuntu-latest needs: yarn-build-wasm steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - uses: taiki-e/install-action@37bdc826eaedac215f638a96472df572feab0f9b with: tool: wasm-pack - name: Download all artifacts uses: actions/download-artifact@v4 - name: Copy prepared wasm run: | ls -R prepared-wasm cp prepared-wasm/kcl_wasm_lib_bg.wasm public mkdir rust/kcl-wasm-lib/pkg cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg - name: Copy prepared ts-rs bindings run: | ls -R prepared-ts-rs-bindings mkdir rust/kcl-lib/bindings cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/ - run: yarn simpleserver:bg if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} - name: Install Chromium Browser if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: yarn playwright install chromium --with-deps - name: run unit tests for kcl samples if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: yarn test:unit:kcl-samples env: VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} yarn-unit-test: runs-on: ubuntu-latest needs: yarn-build-wasm steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' - run: yarn install - uses: taiki-e/install-action@37bdc826eaedac215f638a96472df572feab0f9b with: tool: wasm-pack - name: Download all artifacts uses: actions/download-artifact@v4 - name: Copy prepared wasm run: | ls -R prepared-wasm cp prepared-wasm/kcl_wasm_lib_bg.wasm public mkdir rust/kcl-wasm-lib/pkg cp prepared-wasm/kcl_wasm_lib* rust/kcl-wasm-lib/pkg - name: Copy prepared ts-rs bindings run: | ls -R prepared-ts-rs-bindings mkdir rust/kcl-lib/bindings cp -r prepared-ts-rs-bindings/* rust/kcl-lib/bindings/ - run: yarn simpleserver:bg if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} - name: Install Chromium Browser if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: yarn playwright install chromium --with-deps - name: Run unit tests if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} run: xvfb-run -a yarn test:unit env: VITE_KC_DEV_TOKEN: ${{ secrets.KITTYCAD_API_TOKEN_DEV }} - name: Check for changes if: ${{ github.event_name != 'release' && github.event_name != 'schedule' }} id: git-check run: | git add src/lang/std/artifactMapGraphs if git status src/lang/std/artifactMapGraphs | grep -q "Changes to be committed" then echo "modified=true" >> $GITHUB_OUTPUT else echo "modified=false" >> $GITHUB_OUTPUT fi - name: Commit changes, if any if: ${{ github.event_name != 'release' && github.event_name != 'schedule' && steps.git-check.outputs.modified == 'true' }} run: | git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.name "github-actions[bot]" git remote set-url origin https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git git fetch origin echo ${{ github.head_ref }} git checkout ${{ github.head_ref }} # TODO when webkit works on ubuntu remove the os part of the commit message git commit -am "Look at this (photo)Graph *in the voice of Nickelback*" || true git push git push origin ${{ github.head_ref }}