Skip to content

Commit

Permalink
chore(ci): improve codegen actions (#390)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sec-ant authored May 19, 2024
1 parent 6d700c6 commit 4890c0c
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 16 deletions.
14 changes: 0 additions & 14 deletions .github/actions/run-codegen-rules/action.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions .github/actions/run-codegen/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run codegen
description: Run codegen
inputs:
kinds:
description: Which kinds of codegen to run
required: true
default: metadata, rules
version:
description: The version of Biome
required: true
default: "0.0.0"

runs:
using: composite
steps:
- name: Setup Rust toolchain
uses: ./.github/actions/setup-rust-toolchain
- name: Codegen
shell: bash
run: |
kinds_input='${{ inputs.kinds }}'
# Split the string into an array based on comma or newline delimiter
IFS=$'\n,' read -r -a kinds_array <<< "$kinds_input"
# Trim whitespace from each element and filter out empty elements
kinds=()
for kind in "${kinds_array[@]}"; do
kind=$(echo "$kind" | sed 's/^[[:space:]]*//' | sed 's/[[:space:]]*$//')
if [ -n "$kind" ]; then
kinds+=("$kind")
fi
done
for kind in "${kinds[@]}"; do
echo "Running codegen for $kind"
cargo run --manifest-path codegen/Cargo.toml "$kind"
done
env:
RUST_LOG: info
RUST_BACKTRACE: "1"
CARGO_INCREMENTAL: "1"
BIOME_VERSION: ${{ inputs.version }}
7 changes: 5 additions & 2 deletions .github/workflows/pin-submodule-and-run-codegen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@ jobs:
run: |
git fetch origin main --unshallow
git checkout ${{ env.COMMIT_ID }}
- name: Run codegen rules
uses: ./.github/actions/run-codegen-rules
- name: Run codegen
uses: ./.github/actions/run-codegen
with:
kinds: metadata, rules
version: "0.0.0"
- name: Create pull request
id: create-pull-request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/run-codegen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run codegen
on:
workflow_dispatch:
inputs:
kinds:
description: Which kinds of codegen to run
type: string
required: true
default: metadata, rules
version:
description: The version of Biome
type: string
required: true
default: "0.0.0"

permissions:
actions: write
contents: write
pull-requests: write

jobs:
run-codegen:
runs-on: ubuntu-latest
concurrency:
group: "run-codegen-${{ github.event_name }}"
cancel-in-progress: true
steps:
- name: Checkout repository
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
submodules: true
- name: Run codegen
uses: ./.github/actions/run-codegen
with:
kinds: ${{ inputs.kinds }}
version: ${{ inputs.version }}
- name: Create pull request
id: create-pull-request
uses: peter-evans/create-pull-request@6d6857d36972b65feb161a90e484f2984215f83e # v6.0.5
with:
branch: "chore/run-codegen-${{ github.event_name }}"
author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
title: "chore(ci): run codegen ${{ inputs.kinds }}"
commit-message: "chore(ci): run codegen ${{ inputs.kinds }}"
body: |
Run codegen ${{ inputs.kinds }}.
`BIOME_VERSION=${{ inputs.version }}`
labels: CI-Codegen
- name: Auto merge
if: ${{ steps.create-pull-request.outputs.pull-request-operation != 'closed' && steps.create-pull-request.outputs.pull-request-number != '' }}
run: gh pr merge --squash --auto --delete-branch ${{ steps.create-pull-request.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ pnpm init:biome
# generate only rules files
pnpm codegen:rules

# generate only rules metadata
pnpm codegen:metadata

# generate only release files
pnpm codegen:release-files

Expand Down

0 comments on commit 4890c0c

Please sign in to comment.