Add CI Job to check generate file changes #299
Workflow file for this run
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: Checks | |
on: | |
pull_request: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
check: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run check | |
generate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Restore Cargo cache | |
id: cargo-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Add Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
targets: wasm32-unknown-unknown | |
- name: Install dependencies | |
run: npm ci | |
- name: Set env | |
run: | | |
release=$(curl --silent "https://api.github.com/repos/dfinity/candid/releases/latest" | grep -e '"tag_name"' | cut -c 16-25) | |
echo "DIDC_RELEASE=$(echo $release)" >> $GITHUB_ENV | |
- name: Restore didc cache | |
id: didc-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: /usr/local/bin/didc | |
key: ${{ runner.os }}-didc-${{ env.DIDC_RELEASE }} | |
- name: Add didc dependency | |
if: steps.didc-cache.outputs.cache-hit != 'true' | |
run: | | |
curl -SL https://github.com/dfinity/candid/releases/download/$DIDC_RELEASE/didc-linux64 > /usr/local/bin/didc | |
chmod +x /usr/local/bin/didc | |
- name: Save didc | |
uses: actions/cache/save@v4 | |
if: steps.didc-cache.outputs.cache-hit != 'true' | |
with: | |
path: /usr/local/bin/didc | |
key: ${{ runner.os }}-didc-${{ env.DIDC_RELEASE }} | |
- name: Install candid-extractor | |
if: steps.cargo-cache.outputs.cache-hit != 'true' | |
run: cargo install candid-extractor | |
- name: Generating candids | |
run: ENV=github npm run generate | |
- name: Save Cargo | |
uses: actions/cache/save@v4 | |
if: steps.cargo-cache.outputs.cache-hit != 'true' | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check if files are touched | |
run: if [[ -n $(git status --porcelain) ]]; then echo "Files diff. Failed. Exiting" >&2 && exit 1; else echo "PASSED"; fi | |
may-merge: | |
needs: ['check', 'lint', 'generate'] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Cleared for merging | |
run: echo OK |