diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 7bcb5df2c2..63cd1b2910 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -1,11 +1,7 @@ name: 🌌 Test Build -on: [pull_request] - -# Make sure jobs cannot overlap (e.g. one from push and one from schedule). -concurrency: - group: pr-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-ci - cancel-in-progress: true +on: + workflow_call: jobs: build: @@ -13,29 +9,29 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 + + # Configure the build environment. - # Configure the build environment. + - name: Install Ruby 3.1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.1" + # Runs 'bundle install' and caches installed gems automatically + bundler-cache: true - - name: Install Ruby 3.1 - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.1' - # Runs 'bundle install' and caches installed gems automatically - bundler-cache: true + - name: Install Minify + run: sudo apt-get update && sudo apt-get install minify - - name: Install Minify - run: sudo apt-get update && sudo apt-get install minify + # Build the website. - # Build the website. + - name: Build the static website + run: bundle exec jekyll build - - name: Build the static website - run: bundle exec jekyll build + # Upload resulting "_site" directory as artifact - # Upload resulting "_site" directory as artifact - - - uses: actions/upload-artifact@v4 - with: - name: site - path: _site/ + - uses: actions/upload-artifact@v4 + with: + name: site + path: _site/ diff --git a/.github/workflows/runner.yml b/.github/workflows/runner.yml new file mode 100644 index 0000000000..c008ba8942 --- /dev/null +++ b/.github/workflows/runner.yml @@ -0,0 +1,20 @@ +name: 🔗 GHA +on: [push, pull_request, merge_group] + +concurrency: + group: ${{ github.workflow }}|${{ github.ref_name }} + cancel-in-progress: true + +jobs: + # First stage: Only static checks, fast and prevent expensive builds from running. + + static-checks: + if: "!vars.DISABLE_GODOT_CI" + name: 📊 Static checks + uses: ./.github/workflows/static_checks.yml + + # Second stage: test build the PR + test-build: + name: 🌌 Test Build + needs: static-checks + uses: ./.github/workflows/build-pr.yml diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 0000000000..ebfc92cb17 --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,31 @@ +name: 📊 Static Checks +on: + workflow_call: + +jobs: + static-checks: + name: Code style and file formatting + runs-on: ubuntu-24.04 + timeout-minutes: 30 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Get changed files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + if [ "${{ github.event_name }}" == "pull_request" ]; then + files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true) + elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then + files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true) + fi + echo "$files" >> changed.txt + cat changed.txt + files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "\"./{}\""' | tr '\n' ' ') + echo "CHANGED_FILES=$files" >> $GITHUB_ENV + + - name: pre-commit checks + uses: pre-commit/action@v3.0.1 + with: + extra_args: --files ${{ env.CHANGED_FILES }} diff --git a/.gitignore b/.gitignore index 9fc5610776..a86fe5c7d2 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ $RECYCLE.BIN/ *.msm *.msp *.lnk + +# Python +.venv/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..78f420bf40 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +default_language_version: + python: python3 + +exclude: | + ^( + + )$ + +repos: + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + additional_dependencies: [tomli]