diff options
Diffstat (limited to '.github/workflows')
-rw-r--r-- | .github/workflows/benchmark.yml | 112 | ||||
-rw-r--r-- | .github/workflows/check-merge.yml | 96 | ||||
-rw-r--r-- | .github/workflows/check.yml | 52 | ||||
-rw-r--r-- | .github/workflows/ci.yml | 256 | ||||
-rw-r--r-- | .github/workflows/cleanup-cache.yml | 44 | ||||
-rw-r--r-- | .github/workflows/congrats.yml | 16 | ||||
-rw-r--r-- | .github/workflows/continuous_benchmark.yml | 56 | ||||
-rw-r--r-- | .github/workflows/examples-deploy.yml | 22 | ||||
-rw-r--r-- | .github/workflows/format.yml | 15 | ||||
-rw-r--r-- | .github/workflows/issue-labeled.yml | 47 | ||||
-rw-r--r-- | .github/workflows/issue-needs-repro.yml | 18 | ||||
-rw-r--r-- | .github/workflows/issue-opened.yml | 23 | ||||
-rw-r--r-- | .github/workflows/label.yml | 16 | ||||
-rw-r--r-- | .github/workflows/preview-release.yml | 64 | ||||
-rw-r--r-- | .github/workflows/release.yml | 75 | ||||
-rw-r--r-- | .github/workflows/scripts.yml | 52 | ||||
-rw-r--r-- | .github/workflows/sync-examples.yml | 86 | ||||
-rw-r--r-- | .github/workflows/test-hosts.yml | 48 |
18 files changed, 1098 insertions, 0 deletions
diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 000000000..fdb19edf4 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -0,0 +1,112 @@ +name: Benchmark + +on: + issue_comment: + types: [created] + workflow_dispatch: + +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + +jobs: + benchmark: + if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!bench') }} + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + PR-BENCH: ${{ steps.benchmark-pr.outputs.BENCH_RESULT }} + MAIN-BENCH: ${{ steps.benchmark-main.outputs.BENCH_RESULT }} + steps: + - name: Check if user has write access + uses: lannonbr/repo-permission-check-action@2bb8c89ba8bf115c4bfab344d6a6f442b24c9a1f # 2.0.2 + with: + permission: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # https://github.com/actions/checkout/issues/331#issuecomment-1438220926 + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + ref: refs/pull/${{ github.event.issue.number }}/head + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Get bench command + id: bench-command + env: + # protects from untrusted user input and command injection + COMMENT: ${{ github.event.comment.body }} + run: | + benchcmd=$(echo "$COMMENT" | grep '!bench' | awk -F ' ' '{print $2}') + echo "bench=$benchcmd" >> $GITHUB_OUTPUT + shell: bash + + - name: Run benchmark + id: benchmark-pr + run: | + result=$(pnpm run --silent benchmark ${{ steps.bench-command.outputs.bench }}) + processed=$(node ./benchmark/ci-helper.js "$result") + echo "BENCH_RESULT<<BENCHEOF" >> $GITHUB_OUTPUT + echo "### PR Benchmark" >> $GITHUB_OUTPUT + echo "$processed" >> $GITHUB_OUTPUT + echo "BENCHEOF" >> $GITHUB_OUTPUT + shell: bash + + # main benchmark + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + persist-credentials: false + ref: "main" + + - name: Install + run: | + pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Run benchmark + id: benchmark-main + run: | + result=$(pnpm run --silent benchmark ${{ steps.bench-command.outputs.bench }}) + processed=$(node ./benchmark/ci-helper.js "$result") + echo "BENCH_RESULT<<BENCHEOF" >> $GITHUB_OUTPUT + echo "### Main Benchmark" >> $GITHUB_OUTPUT + echo "$processed" >> $GITHUB_OUTPUT + echo "BENCHEOF" >> $GITHUB_OUTPUT + shell: bash + + output-benchmark: + if: ${{ github.repository_owner == 'withastro' && github.event.issue.pull_request && startsWith(github.event.comment.body, '!bench') }} + needs: [benchmark] + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - name: Comment PR + uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4 + continue-on-error: true + with: + issue-number: ${{ github.event.issue.number }} + body: | + ${{ needs.benchmark.outputs.PR-BENCH }} + + ${{ needs.benchmark.outputs.MAIN-BENCH }} + edit-mode: replace diff --git a/.github/workflows/check-merge.yml b/.github/workflows/check-merge.yml new file mode 100644 index 000000000..d4d659ea1 --- /dev/null +++ b/.github/workflows/check-merge.yml @@ -0,0 +1,96 @@ +name: Check mergeability + +on: pull_request_target + +permissions: + pull-requests: write + checks: write + statuses: write + +jobs: + check: + runs-on: ubuntu-latest + steps: + - name: Check if there is already a block on this PR + id: blocked + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + issue_number: ${{ github.event.number }} + with: + script: | + const { data: reviews } = await github.rest.pulls.listReviews({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: process.env.issue_number, + }); + + for (const review of reviews) { + if (review.user.login === 'github-actions[bot]' && review.state === 'CHANGES_REQUESTED') { + return 'true' + } + } + return 'false' + result-encoding: string + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + if: steps.blocked.outputs.result != 'true' + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Get changed files in the .changeset folder + id: changed-files + uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5 + if: steps.blocked.outputs.result != 'true' + with: + files: | + .changeset/**/*.md + + - name: Check if any changesets contain minor or major changes + id: check + if: steps.blocked.outputs.result != 'true' + env: + ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + echo "Checking for changesets marked as minor or major" + echo "found=false" >> $GITHUB_OUTPUT + + regex="[\"']astro[\"']: (minor|major)" + for file in ${ALL_CHANGED_FILES}; do + if [[ $(cat $file) =~ $regex ]]; then + version="${BASH_REMATCH[1]}" + echo "version=$version" >> $GITHUB_OUTPUT + echo "found=true" >> $GITHUB_OUTPUT + echo "$file has a $version release tag" + fi + done + + - name: Add label + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + if: steps.check.outputs.found == 'true' + env: + issue_number: ${{ github.event.number }} + with: + script: | + github.rest.issues.addLabels({ + issue_number: process.env.issue_number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['semver: ${{ steps.check.outputs.version }}'] + }); + + - name: Change PR Status + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + if: steps.check.outputs.found == 'true' + env: + issue_number: ${{ github.event.number }} + with: + script: | + github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: process.env.issue_number, + event: 'REQUEST_CHANGES', + body: 'This PR is blocked because it contains a `${{ steps.check.outputs.version }}` changeset. A reviewer will merge this at the next release if approved.' + }); diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 000000000..aebb3a4fd --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,52 @@ +name: Examples astro check + +on: + workflow_dispatch: + push: + branches: + - main + merge_group: + pull_request: + paths: + - "examples/**" + - ".github/workflows/check.yml" + - "scripts/smoke/check.js" + - "packages/astro/src/types/public/**" + - "pnpm-lock.yaml" + - "packages/astro/types.d.ts" + +env: + ASTRO_TELEMETRY_DISABLED: true + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + +jobs: + check: + name: astro check + runs-on: ubuntu-latest + timeout-minutes: 7 + steps: + - name: Check out repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Status + run: git status + + - name: astro check + run: pnpm run test:check-examples diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..7abb53acb --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,256 @@ +name: CI + +on: + workflow_dispatch: + push: + branches: + - main + merge_group: + pull_request: + paths-ignore: + - ".vscode/**" + - "**/*.md" + - ".github/ISSUE_TEMPLATE/**" + +# Automatically cancel older in-progress jobs on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash + +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + ASTRO_TELEMETRY_DISABLED: true + # 7 GiB by default on GitHub, setting to 6 GiB + # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + NODE_OPTIONS: --max-old-space-size=6144 + +jobs: + # Build primes out Turbo build cache and pnpm cache + build: + name: "Build: ${{ matrix.os }}" + runs-on: ${{ matrix.os }} + timeout-minutes: 3 + strategy: + matrix: + OS: [ubuntu-latest, windows-latest] + NODE_VERSION: [22] + fail-fast: true + steps: + # Disable crlf so all OS can share the same Turbo cache + # https://github.com/actions/checkout/issues/135 + - name: Disable git crlf + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup node@${{ matrix.NODE_VERSION }} + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ matrix.NODE_VERSION }} + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + # Only build in ubuntu as windows can share the build cache. + # Also only build in core repo as forks don't have access to the Turbo cache. + - name: Build Packages + if: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'withastro' }} + run: pnpm run build + + lint: + name: Lint + runs-on: ubuntu-latest + timeout-minutes: 5 + needs: build + steps: + - name: Disable git crlf + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + # The cache doesn't contain prebuild files and causes knip to fail + run: pnpm run build --force + + - name: Lint source code + run: pnpm run lint:ci + + - name: Lint publish code + run: pnpm run publint + + test: + name: "Test: ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})" + runs-on: ${{ matrix.os }} + timeout-minutes: 25 + needs: build + strategy: + matrix: + OS: [ubuntu-latest] + NODE_VERSION: [18, 20, 22] + include: + - os: macos-14 + NODE_VERSION: 22 + - os: windows-latest + NODE_VERSION: 22 + fail-fast: false + env: + NODE_VERSION: ${{ matrix.NODE_VERSION }} + steps: + - name: Disable git crlf + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup node@${{ matrix.NODE_VERSION }} + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ matrix.NODE_VERSION }} + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Test + run: pnpm run test + + e2e: + name: "Test (E2E): ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})" + runs-on: ${{ matrix.os }} + timeout-minutes: 25 + needs: build + strategy: + matrix: + OS: [ubuntu-latest, windows-latest] + NODE_VERSION: [22] + fail-fast: false + env: + NODE_VERSION: ${{ matrix.NODE_VERSION }} + steps: + - name: Disable git crlf + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup node@${{ matrix.NODE_VERSION }} + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ matrix.NODE_VERSION }} + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Test + run: pnpm run test:e2e + + smoke: + name: "Test (Smoke): ${{ matrix.os }} (node@${{ matrix.NODE_VERSION }})" + runs-on: ${{ matrix.os }} + timeout-minutes: 25 + needs: build + strategy: + matrix: + OS: [ubuntu-latest, windows-latest] + NODE_VERSION: [22] + env: + NODE_VERSION: ${{ matrix.NODE_VERSION }} + steps: + - name: Disable git crlf + run: git config --global core.autocrlf false + + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup node@${{ matrix.NODE_VERSION }} + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ matrix.NODE_VERSION }} + cache: "pnpm" + + - name: Checkout docs + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + repository: withastro/docs + path: smoke/docs + # For a commit event on the `next` branch (`ref_name`), use the `5.0.0-beta` branch. + # For a pull_request event merging into the `next` branch (`base_ref`), use the `5.0.0-beta` branch. + # NOTE: For a pull_request event, the `ref_name` is something like `<pr-number>/merge` than the branch name. + # NOTE: Perhaps docs repo should use a consistent `next` branch in the future. + ref: ${{ (github.ref_name == 'next' || github.base_ref == 'next') && '5.0.0-beta' || 'main' }} + + - name: Install dependencies + run: pnpm install --no-frozen-lockfile + + # Reset lockfile changes so that Turbo can reuse the old build cache + - name: Reset lockfile changes + run: git reset --hard + + - name: Build Packages + run: pnpm run build + + - name: Remove docs translations except for English and Korean + run: find smoke/docs/src/content/docs ! -name 'en' ! -name 'ko' -type d -mindepth 1 -maxdepth 1 -exec rm -rf {} + + + - name: Check if docs changed + id: changes + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 + with: + filters: | + docs: + - 'packages/integrations/*/README.md' + - "packages/astro/src/types/public/**" + - 'packages/astro/src/core/errors/errors-data.ts' + + - name: Build autogenerated docs pages from current astro branch + if: ${{ steps.changes.outputs.docs == 'true' }} + run: cd smoke/docs && pnpm docgen && pnpm docgen:errors + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SOURCE_REPO: ${{ github.event.pull_request.head.repo.full_name || github.event.repository.full_name }} + SOURCE_BRANCH: ${{ github.head_ref || github.ref_name }} + + - name: Test + run: pnpm run test:smoke + env: + SKIP_OG: true + PUBLIC_TWO_LANG: true diff --git a/.github/workflows/cleanup-cache.yml b/.github/workflows/cleanup-cache.yml new file mode 100644 index 000000000..57429c444 --- /dev/null +++ b/.github/workflows/cleanup-cache.yml @@ -0,0 +1,44 @@ +name: Cleanup cache + +on: + schedule: + - cron: "0 11 * * *" + pull_request: + types: + - closed + +jobs: + cleanup: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Cleanup caches older than 5 days + if: github.event_name == 'schedule' + uses: MyAlbum/purge-cache@881eb5957687193fa612bf74c0042adc78ea5e54 # v2.2.0 + with: + max-age: 432000 + + # https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries + - name: Cleanup on PR close + if: github.event_name == 'pull_request' + run: | + gh extension install actions/gh-actions-cache + + REPO=${{ github.repository }} + BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge" + + echo "Fetching list of cache key" + cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 ) + + ## Setting this to not fail the workflow while deleting cache keys. + set +e + echo "Deleting caches..." + for cacheKey in $cacheKeysForPR + do + gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm + done + echo "Done" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/congrats.yml b/.github/workflows/congrats.yml new file mode 100644 index 000000000..4052bdac8 --- /dev/null +++ b/.github/workflows/congrats.yml @@ -0,0 +1,16 @@ +name: Congratsbot + +on: + push: + branches: + - main + +jobs: + congrats: + name: congratsbot + if: ${{ github.repository_owner == 'withastro' && github.event.head_commit.message != '[ci] format' }} + uses: withastro/automation/.github/workflows/congratsbot.yml@main + with: + EMOJIS: '🎉,🎊,🧑🚀,🥳,🙌,🚀,👏,<:houston_golden:1068575433647456447>,<:astrocoin:894990669515489301>,<:astro_pride:1130501345326157854>' + secrets: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_CONGRATS }} diff --git a/.github/workflows/continuous_benchmark.yml b/.github/workflows/continuous_benchmark.yml new file mode 100644 index 000000000..9a5a3fef9 --- /dev/null +++ b/.github/workflows/continuous_benchmark.yml @@ -0,0 +1,56 @@ +name: Continuous benchmark + +on: + workflow_dispatch: + pull_request: + branches: + - main + paths: + - 'packages/astro/src/**/*.ts' + - 'benchmark/**' + push: + branches: + - main + paths: + - 'packages/astro/src/**/*.ts' + - 'benchmark/**' + +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + CODSPEED: true + +jobs: + codspeed: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - name: Check out repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Run the benchmarks + uses: CodSpeedHQ/action@0010eb0ca6e89b80c88e8edaaa07cfe5f3e6664d # v3.5.0 + timeout-minutes: 30 + with: + working-directory: ./benchmark + run: pnpm bench + token: ${{ secrets.CODSPEED_TOKEN }} + diff --git a/.github/workflows/examples-deploy.yml b/.github/workflows/examples-deploy.yml new file mode 100644 index 000000000..06cecbe1e --- /dev/null +++ b/.github/workflows/examples-deploy.yml @@ -0,0 +1,22 @@ +# This workflow runs when changes to examples are pushed to main. +# It calls a build hook on Netlify that will redeploy preview.astro.new with the latest changes. + +name: Redeploy preview.astro.new + +on: + push: + branches: + - main + paths: + - 'examples/**' + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - name: Send a POST request to Netlify to rebuild preview.astro.new + run: 'curl -X POST -d {} ${{ env.BUILD_HOOK }}' + env: + BUILD_HOOK: ${{ secrets.NETLIFY_PREVIEWS_BUILD_HOOK }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..9faaa1886 --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,15 @@ +name: Format + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + prettier: + if: github.repository_owner == 'withastro' + uses: withastro/automation/.github/workflows/format.yml@main + with: + command: "format" + secrets: inherit diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml new file mode 100644 index 000000000..24e5ea152 --- /dev/null +++ b/.github/workflows/issue-labeled.yml @@ -0,0 +1,47 @@ +name: Issue Labeled + +on: + issues: + types: [labeled] + +jobs: + reply-labeled: + if: github.repository == 'withastro/astro' + runs-on: ubuntu-latest + steps: + - name: remove triage + if: contains(github.event.label.description, '(priority)') && contains(github.event.issue.labels.*.name, 'needs triage') + uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0 + with: + actions: "remove-labels" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + labels: "needs triage" + + - name: needs repro + if: github.event.label.name == 'needs repro' + uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0 + with: + actions: "create-comment, remove-labels" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + Hello @${{ github.event.issue.user.login }}. Please provide a [minimal reproduction](https://stackoverflow.com/help/minimal-reproducible-example) using a GitHub repository or [StackBlitz](https://astro.new/repro). Issues marked with `needs repro` will be closed if they have no activity within 3 days. + labels: "needs triage" + - name: wontfix + if: github.event.label.name == 'wontfix' + uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0 + with: + actions: "create-comment, close-issue" + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.issue.number }} + body: | + Hello! + + This is an automated message to let you know that we've triaged this issue and unfortunately, we will be closing it as "not planned". + + We sometimes have to close good ideas (even great ones!) because our limited resources simply do not allow us to pursue all possible features and improvements, and when fixing bugs we have to balance the impact of the bug against the effort required for the fix. Before closing this we considered several factors such as the amount of work involved, the severity of the problem, the number of people affected, whether a workaround is available, and the ongoing cost of maintenance. + + If you're seeing this message and believe you can contribute to this issue, please consider submitting a PR yourself. Astro encourages [community contributions](https://docs.astro.build/en/contribute/)! + + If you have more questions, come and say hi in the [Astro Discord](https://astro.build/chat). diff --git a/.github/workflows/issue-needs-repro.yml b/.github/workflows/issue-needs-repro.yml new file mode 100644 index 000000000..6a6842864 --- /dev/null +++ b/.github/workflows/issue-needs-repro.yml @@ -0,0 +1,18 @@ +name: Close Issues (needs repro) + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + close-issues: + if: github.repository == 'withastro/astro' + runs-on: ubuntu-latest + steps: + - name: needs repro + uses: actions-cool/issues-helper@a610082f8ac0cf03e357eb8dd0d5e2ba075e017e # v3.6.0 + with: + actions: "close-issues" + token: ${{ secrets.GITHUB_TOKEN }} + labels: "needs repro" + inactive-day: 3 diff --git a/.github/workflows/issue-opened.yml b/.github/workflows/issue-opened.yml new file mode 100644 index 000000000..4e6de6fed --- /dev/null +++ b/.github/workflows/issue-opened.yml @@ -0,0 +1,23 @@ +name: Label issues +on: + issues: + types: + - reopened + - opened + +jobs: + label_issues: + runs-on: ubuntu-latest + if: github.repository == 'withastro/astro' + permissions: + issues: write + steps: + - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ["needs triage"] + }) diff --git a/.github/workflows/label.yml b/.github/workflows/label.yml new file mode 100644 index 000000000..616463c27 --- /dev/null +++ b/.github/workflows/label.yml @@ -0,0 +1,16 @@ +# Automatically labels PRs based on the configuration file +# you are probably looking for 👉 `.github/labeler.yml` +name: Label PRs + +on: + - pull_request_target + +jobs: + triage: + runs-on: ubuntu-latest + if: github.repository_owner == 'withastro' + steps: + - uses: actions/labeler@v4 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + sync-labels: true diff --git a/.github/workflows/preview-release.yml b/.github/workflows/preview-release.yml new file mode 100644 index 000000000..2fbf8d665 --- /dev/null +++ b/.github/workflows/preview-release.yml @@ -0,0 +1,64 @@ +name: Preview release + +on: + pull_request: + branches: [main] + types: [labeled] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true + +permissions: + contents: read + actions: write + +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + ASTRO_TELEMETRY_DISABLED: true + # 7 GiB by default on GitHub, setting to 6 GiB + # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + NODE_OPTIONS: --max-old-space-size=6144 + +jobs: + preview: + if: ${{ github.repository_owner == 'withastro' && github.event.label.name == 'pr preview' }} + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + issues: write + pull-requests: write + name: Publish preview release + timeout-minutes: 5 + steps: + - name: Disable git crlf + run: git config --global core.autocrlf false + + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Remove Preview Label + uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 # v1.3.0 + with: + labels: "pr preview" + + - name: Publish packages + run: | + pnpm dlx pkg-pr-new publish --pnpm --compact --no-template 'packages/astro' 'packages/integrations/node' 'packages/integrations/cloudflare' 'packages/integrations/netlify' 'packages/integrations/vercel' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..112613008 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,75 @@ +name: Release + +on: + push: + branches: + - main + - "1-legacy" + - "2-legacy" + - "3-legacy" + - "4-legacy" + +defaults: + run: + shell: bash + +env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + FORCE_COLOR: true + +jobs: + changelog: + name: Changelog PR or Release + if: ${{ github.repository_owner == 'withastro' }} + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Build Packages + run: pnpm run build + + - name: Create Release Pull Request or Publish + id: changesets + uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 + with: + # Note: pnpm install after versioning is necessary to refresh lockfile + version: pnpm run version + publish: pnpm exec changeset publish + commit: "[ci] release" + title: "[ci] release" + env: + # Needs access to push to main + GITHUB_TOKEN: ${{ secrets.FREDKBOT_GITHUB_TOKEN }} + # Needs access to publish to npm + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Generate Announcement + id: message + if: steps.changesets.outputs.published == 'true' + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + run: node .github/scripts/announce.mjs '${{ steps.changesets.outputs.publishedPackages }}' + + - name: Send message on Discord + if: steps.changesets.outputs.published == 'true' + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + uses: Ilshidur/action-discord@0c4b27844ba47cb1c7bee539c8eead5284ce9fa9 # 0.3.2 + with: + args: "${{ steps.message.outputs.DISCORD_MESSAGE }}" diff --git a/.github/workflows/scripts.yml b/.github/workflows/scripts.yml new file mode 100644 index 000000000..f031bbddb --- /dev/null +++ b/.github/workflows/scripts.yml @@ -0,0 +1,52 @@ +name: Scripts + +on: + workflow_dispatch: + pull_request: + branches: + - "main" + paths: + - "packages/astro/src/runtime/client/**/*" + - "!packages/astro/src/runtime/client/dev-toolbar/**/*" + +# Automatically cancel in-progress actions on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + bundle: + name: Bundle Size + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Checkout Main into tmp + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + ref: main + path: main + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: "pnpm" + + - name: Install dependencies + run: pnpm install + + - name: Check Bundle Size + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const { default: script } = await import('${{ github.workspace }}/.github/scripts/bundle-size.mjs') + await script({ github, context }) diff --git a/.github/workflows/sync-examples.yml b/.github/workflows/sync-examples.yml new file mode 100644 index 000000000..45d127447 --- /dev/null +++ b/.github/workflows/sync-examples.yml @@ -0,0 +1,86 @@ +name: Sync examples + +on: + workflow_dispatch: + inputs: + checkout-ref: + type: string + required: false + skip-unchanged-check: + type: boolean + default: false + dry-run: + type: boolean + default: false + push: + branches: + - main + +# Automatically cancel in-progress actions on the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: true + +permissions: + # Allow auto-branch-sync-action to git push + contents: write + +jobs: + sync: + name: Sync branches + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 2 # fetch 2 to compare with previous commit for changes + ref: ${{ inputs.checkout-ref }} + + - name: Detect changesets + uses: bluwy/detect-changesets-action@41d6432bd7bc24b3539228091f88879a18cee39b # v1 + id: detect + + - name: Get pre mode of changesets + id: pre + run: | + if [ -f ./.changeset/pre.json ]; then + pre_value=$(jq -r '.tag' ./.changeset/pre.json) + echo "value=$pre_value" >> $GITHUB_OUTPUT + fi + + # We only do sync if there are no changesets, so we don't accidentally allow users + # to clone examples that may rely on unreleased code + + - name: Sync stable to latest and examples/* branches + if: steps.detect.outputs.has-changesets == 'false' && github.ref == 'refs/heads/main' && steps.pre.outputs.value == '' + uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1 + with: + map: | + / -> latest + /examples/* -> examples/* + skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} + dry-run: ${{ inputs.dry-run == true }} + + - name: Sync prerelease to alpha branch + if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'alpha' + uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1 + with: + map: / -> alpha + skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} + dry-run: ${{ inputs.dry-run == true }} + + - name: Sync prerelease to beta branch + if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'beta' + uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1 + with: + map: / -> beta + skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} + dry-run: ${{ inputs.dry-run == true }} + + - name: Sync prerelease to rc branch + if: steps.detect.outputs.has-changesets == 'false' && steps.pre.outputs.value == 'rc' + uses: bluwy/auto-branch-sync-action@a72b09dc60911f56a1e7093a069f24480ca3d2ab # v1.0.1 + with: + map: / -> rc + skip-unchanged-check: ${{ inputs.skip-unchanged-check == true }} + dry-run: ${{ inputs.dry-run == true }} diff --git a/.github/workflows/test-hosts.yml b/.github/workflows/test-hosts.yml new file mode 100644 index 000000000..f12ed9b40 --- /dev/null +++ b/.github/workflows/test-hosts.yml @@ -0,0 +1,48 @@ +name: Hosted tests + +on: + schedule: + - cron: '0 0 * * 0' + +env: + ASTRO_TELEMETRY_DISABLED: true + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + VERCEL_ORG_ID: ${{ secrets.VERCEL_TEST_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_TEST_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TEST_TOKEN }} + FORCE_COLOR: true + +jobs: + test: + name: Run tests + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Setup PNPM + uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 + + - name: Setup Node + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: 22 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install + + - name: Build Astro + run: pnpm turbo build --filter astro --filter @astrojs/vercel + + - name: Build test project + working-directory: ./packages/integrations/vercel/test/hosted/hosted-astro-project + run: pnpm run build + + - name: Deploy to Vercel + working-directory: ./packages/integrations/vercel/test/hosted/hosted-astro-project + run: pnpm dlx vercel --prod --prebuilt + + - name: Test + run: pnpm run test:e2e:hosts |