diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000..6fb32e7962 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,95 @@ +name: CI + +on: + push: + branches: [develop, beta] + pull_request: + branches: [develop, beta] + +jobs: + build-and-test: + name: ${{ matrix.command_description }} + uses: ./.github/workflows/test.yml + strategy: + fail-fast: false + matrix: + include: + - command_description: Build + command: npm run build + needs_lfs: false + needs_playwright: false + - command_description: Lint + command: npm run lint + needs_lfs: false + needs_playwright: false + - command_description: Less Tests + command: npm run test:less -w packages/stacks-classic + needs_lfs: false + needs_playwright: false + - command_description: Unit Tests + command: npm run test:unit -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs + needs_lfs: false + needs_playwright: true + - command_description: A11y Tests + command: npm run test:a11y -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs + needs_lfs: false + needs_playwright: true + - command_description: Visual Regression Tests + command: npm run test:visual:ci -w packages/stacks-classic -- --config ./visual-runner/stacks-classic-runner-config/web-test-runner.config.ci.mjs + needs_lfs: true + needs_playwright: false # we are using playwright docker image to run visual tests + - command_description: Unit Tests (stacks-svelte) + command: npm run test -w packages/stacks-svelte + needs_lfs: false + needs_playwright: true + with: + command: ${{ matrix.command }} + command_description: ${{ matrix.command_description }} + needs_playwright: ${{ matrix.needs_playwright }} + needs_lfs: ${{ matrix.needs_lfs }} + release: + name: Release (latest or beta) + if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/beta' + needs: [build-and-test] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: "npm" + - name: Install dependencies + run: | + npm ci + npm run build + - name: 🚀 Create/Update Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + version: npm run version + publish: npm run release + title: "chore(new-release)" + commit: "chore(new-release)" + branch: ${{ github.ref == 'refs/heads/beta' && 'beta' || null }} + createGithubReleases: ${{ github.ref == 'refs/heads/develop' }} + env: + GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} + NPM_TOKEN: ${{ secrets.NPM_API_KEY }} + - name: 🔄 Update stackoverflow.design docs + # Only run this step if publish succeeded and actually released something + if: ${{ steps.changesets.outputs.published == 'true' && github.ref_name == 'develop' }} + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git fetch origin + git checkout production + git merge --no-ff --allow-unrelated-histories origin/develop -m "chore: merge develop into production" + git push origin production + env: + GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} + +# cancel the jobs if another workflow is kicked off for the same branch +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 82708bb98e..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Release - -on: - workflow_run: - workflows: - - CI - branches: - - develop - types: - - completed - -permissions: write-all - -jobs: - release: - name: Release - # run only if the CI workflow is successful - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - steps: - - name: ⬇️ Checkout - uses: - actions/checkout@v4 - # make sure to checkout the commit that triggered the CI workflow - # (which is not necessarily the latest commit) - with: - ref: ${{ github.event.workflow_run.head_commit.id }} - - - name: ⎔ Setup node - uses: actions/setup-node@v4 - with: - node-version: "lts/*" - - - name: 🏗 Install and Build - run: | - npm ci - npm run build - - - name: 🚀 Create/Update Release Pull Request or Publish to npm - id: changesets - uses: changesets/action@v1 - with: - version: npm run version - publish: npm run release - title: "chore(new-release)" - commit: "chore(new-release)" - env: - GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} - NPM_TOKEN: ${{ secrets.NPM_API_KEY }} - - - name: 🔄 Update stackoverflow.design docs - # Only run this step if publish succeeded and actually released something - if: steps.changesets.outputs.published == 'true' - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git fetch origin - git checkout production - git merge --no-ff --allow-unrelated-histories origin/develop -m "chore: merge develop into production" - git push origin production - env: - GITHUB_TOKEN: ${{ secrets.STACKS_TOOLING_GH_RW_PAT }} - -# cancel the jobs if another workflow is kicked off for the same branch -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml deleted file mode 100644 index ca036b1b65..0000000000 --- a/.github/workflows/workflow.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: CI - -on: - push: - branches: [develop] - pull_request: - branches: [develop] - # this is to ensure the pipeline runs at least once a day - # even when there is no active development in the codebase - schedule: - - cron: '0 6 * * 1-5' # every weekday at 6am UTC - -jobs: - build-and-test: - name: ${{ matrix.command_description }} - uses: ./.github/workflows/test.yml - strategy: - fail-fast: false - matrix: - include: - - command_description: Build - command: npm run build - needs_lfs: false - needs_playwright: false - - command_description: Lint - command: npm run lint - needs_lfs: false - needs_playwright: false - - command_description: Less Tests - command: npm run test:less -w packages/stacks-classic - needs_lfs: false - needs_playwright: false - - command_description: Unit Tests - command: npm run test:unit -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs - needs_lfs: false - needs_playwright: true - - command_description: A11y Tests - command: npm run test:a11y -w packages/stacks-classic -- --config web-test-runner.config.ci.mjs - needs_lfs: false - needs_playwright: true - - command_description: Visual Regression Tests - command: npm run test:visual:ci -w packages/stacks-classic -- --config ./visual-runner/stacks-classic-runner-config/web-test-runner.config.ci.mjs - needs_lfs: true - needs_playwright: false # we are using playwright docker image to run visual tests - - command_description: Unit Tests (stacks-svelte) - command: npm run test -w packages/stacks-svelte - needs_lfs: false - needs_playwright: true - with: - command: ${{ matrix.command }} - command_description: ${{ matrix.command_description }} - needs_playwright: ${{ matrix.needs_playwright }} - needs_lfs: ${{ matrix.needs_lfs }} \ No newline at end of file