Skip to content

Commit 587504e

Browse files
committed
Add pre-commit and codespell check
Add runner.yml also to make sure to run pre-commit before testing the project
1 parent 7873f0d commit 587504e

File tree

4 files changed

+87
-26
lines changed

4 files changed

+87
-26
lines changed

.github/workflows/build-pr.yml

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
11
name: 🌌 Test Build
22

3-
on: [pull_request]
4-
5-
# Make sure jobs cannot overlap (e.g. one from push and one from schedule).
6-
concurrency:
7-
group: pr-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-ci
8-
cancel-in-progress: true
3+
on:
4+
workflow_call:
95

106
jobs:
117
build:
128
name: Build sources from the PR branch
139
runs-on: ubuntu-latest
1410

1511
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
# Configure the build environment.
1816

19-
# Configure the build environment.
17+
- name: Install Ruby 3.1
18+
uses: ruby/setup-ruby@v1
19+
with:
20+
ruby-version: "3.1"
21+
# Runs 'bundle install' and caches installed gems automatically
22+
bundler-cache: true
2023

21-
- name: Install Ruby 3.1
22-
uses: ruby/setup-ruby@v1
23-
with:
24-
ruby-version: '3.1'
25-
# Runs 'bundle install' and caches installed gems automatically
26-
bundler-cache: true
24+
- name: Install Minify
25+
run: sudo apt-get update && sudo apt-get install minify
2726

28-
- name: Install Minify
29-
run: sudo apt-get update && sudo apt-get install minify
27+
# Build the website.
3028

31-
# Build the website.
29+
- name: Build the static website
30+
run: bundle exec jekyll build
3231

33-
- name: Build the static website
34-
run: bundle exec jekyll build
32+
# Upload resulting "_site" directory as artifact
3533

36-
# Upload resulting "_site" directory as artifact
37-
38-
- uses: actions/upload-artifact@v4
39-
with:
40-
name: site
41-
path: _site/
34+
- uses: actions/upload-artifact@v4
35+
with:
36+
name: site
37+
path: _site/

.github/workflows/runner.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 🔗 GHA
2+
on: [push, pull_request, merge_group]
3+
4+
concurrency:
5+
group: ${{ github.workflow }}|${{ github.ref_name }}
6+
cancel-in-progress: true
7+
8+
jobs:
9+
# First stage: Only static checks, fast and prevent expensive builds from running.
10+
11+
static-checks:
12+
if: "!vars.DISABLE_GODOT_CI"
13+
name: 📊 Static checks
14+
uses: ./.github/workflows/static_checks.yml
15+
16+
# Second stage: test build the PR
17+
test-build:
18+
name: 🌌 Test Build
19+
needs: static-checks
20+
uses: ./.github/workflows/build-pr.yml
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: 📊 Static Checks
2+
on:
3+
workflow_call:
4+
5+
jobs:
6+
static-checks:
7+
name: Code style and file formatting
8+
runs-on: ubuntu-24.04
9+
timeout-minutes: 30
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Get changed files
15+
env:
16+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
run: |
18+
if [ "${{ github.event_name }}" == "pull_request" ]; then
19+
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
20+
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
21+
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
22+
fi
23+
echo "$files" >> changed.txt
24+
cat changed.txt
25+
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ')
26+
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
27+
28+
- name: pre-commit checks
29+
uses: pre-commit/[email protected]
30+
with:
31+
extra_args: --files ${{ env.CHANGED_FILES }}

.pre-commit-config.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
default_language_version:
2+
python: python3
3+
4+
exclude: |
5+
^(
6+
7+
)$
8+
9+
repos:
10+
- repo: https://github.com/codespell-project/codespell
11+
rev: v2.3.0
12+
hooks:
13+
- id: codespell
14+
additional_dependencies: [tomli]

0 commit comments

Comments
 (0)