chore(backend): Tighten formatting rules #8500
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: Binding Checks | |
on: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
generate: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Create GitHub App Token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
continue-on-error: true | |
with: | |
app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }} | |
private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }} | |
- name: Check if commits can be added | |
id: check_can_add_commit | |
run: | | |
echo steps.app-token.outputs.token null ${{ steps.app-token.outputs.token == null}} | |
echo steps.app-token.outputs.token empty ${{ steps.app-token.outputs.token == ''}} | |
echo "can_add_commit=${{ steps.app-token.outputs.token != '' && github.event_name == 'pull_request' }}" >> $GITHUB_OUTPUT | |
- name: Checkout code | |
if: steps.check_can_add_commit.outputs.can_add_commit == 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
token: ${{ steps.app-token.outputs.token }} | |
- name: Checkout code | |
if: steps.check_can_add_commit.outputs.can_add_commit == 'false' | |
uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: changes | |
with: | |
filters: | | |
src: | |
- # Any new or changed canisters | |
'dfx.json' | |
- # Any new or changed .did files | |
'**/*.did' | |
- # Scripts, GitHub actions that contain 'backend' in their path. | |
'**/*backend*' | |
- # The backend source code | |
'src/backend/**' | |
- 'src/shared/**' | |
- # Rust files such as Cargo.lock, Cargo.toml and rust-toolchain.toml | |
'**/Cargo*' | |
- '**/*rust*' | |
- # Scripts that download external Candid files, with false positives. | |
'scripts/build.*.sh' | |
- # This workflow | |
'.github/workflows/binding-checks.yml' | |
- name: Build oisy-backend WASM | |
if: steps.changes.outputs.src == 'true' | |
uses: ./.github/actions/oisy-backend | |
- name: Prepare | |
if: steps.changes.outputs.src == 'true' | |
uses: ./.github/actions/prepare | |
- name: Install dfx | |
if: steps.changes.outputs.src == 'true' | |
uses: dfinity/setup-dfx@main | |
- name: Install binstall | |
if: steps.changes.outputs.src == 'true' | |
run: scripts/setup cargo-binstall | |
- name: Install candid-extractor | |
if: steps.changes.outputs.src == 'true' | |
run: cargo binstall --no-confirm candid-extractor@0.1.4 && candid-extractor --version | |
- name: Install didc | |
if: steps.changes.outputs.src == 'true' | |
run: ./scripts/setup didc | |
- name: Generate bindings | |
if: steps.changes.outputs.src == 'true' | |
run: npm run generate | |
- name: Check bindings | |
id: check_changes | |
if: steps.changes.outputs.src == 'true' | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "changes_detected=true" >> $GITHUB_OUTPUT | |
else | |
echo "changes_detected=false" >> $GITHUB_OUTPUT | |
fi | |
- name: Commit bindings | |
if: steps.changes.outputs.src == 'true' && steps.check_can_add_commit.outputs.can_add_commit == 'true' && steps.check_changes.outputs.changes_detected == 'true' | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: . | |
default_author: github_actions | |
message: '🤖 Apply bindings changes' | |
- name: Provide diff | |
if: steps.changes.outputs.src == 'true' && steps.check_can_add_commit.outputs.can_add_commit == 'false' && steps.check_changes.outputs.changes_detected == 'true' | |
run: | | |
echo "FIX: Please execute npm run generate" | |
git diff | |
exit 1 | |
binding-checks-pass: | |
needs: ['generate'] | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Cleared for merging | |
run: echo OK |