chore(ci): reusable worflow #1381
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
paths-ignore: | |
- 'website/**' | |
push: | |
# Ensures cache is computed on main branch so that it can be reused on all PRs | |
branches: [ "main" ] | |
paths-ignore: | |
- 'website/**' | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
monorepo: | |
runs-on: ${{ matrix.os }} | |
# Uncomment to debug discrepancies between published package and local one | |
# services: | |
# verdaccio: | |
# # See https://github.com/actions/runner/issues/822#issuecomment-1524826092 | |
# image: ${{ (matrix.os == 'ubuntu-latest') && 'verdaccio/verdaccio' || '' }} | |
# ports: | |
# - 4873:4873 | |
strategy: | |
matrix: | |
# os: [ubuntu-latest, macos-latest, windows-latest] | |
os: [ubuntu-latest] | |
node: [20] | |
include: | |
- os: ubuntu-latest | |
node: 18 | |
- os: ubuntu-latest | |
node: 22 | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node }} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
run_install: false | |
# - uses: oven-sh/setup-bun@v2 | |
# name: Install bun | |
# with: | |
# bun-version: "1.1.24" | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
- name: mkdir temp folder | |
run: mkdir -p ${{ runner.temp }}/bati-cache | |
- uses: actions/cache@v4 | |
name: Setup pnpm cache | |
with: | |
path: ${{ env.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
# - uses: actions/cache@v4 | |
# # REALLY slow on windows | |
# if: matrix.os != 'windows-latest' | |
# name: Setup bun cache | |
# with: | |
# path: ~/.bun/install/cache | |
# # Uses pnpm hash to avoid too many cache creations | |
# key: ${{ runner.os }}-bun-${{ hashFiles('**/pnpm-lock.yaml') }} | |
# restore-keys: | | |
# ${{ runner.os }}-bun- | |
- name: Cache for Turbo | |
uses: rharkor/[email protected] | |
# - name: Install global dependencies | |
# if: matrix.os == 'ubuntu-latest' | |
# run: pnpm install --global npm-cli-login | |
# - name: Login to verdaccio | |
# if: matrix.os == 'ubuntu-latest' | |
# run: npm-cli-login | |
# env: | |
# NPM_USER: bati | |
# NPM_PASS: bati | |
# NPM_EMAIL: [email protected] | |
# NPM_REGISTRY: http://localhost:4873 | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build packages | |
run: pnpm run build | |
env: | |
# self-contained Bati CLI, lighter artifact | |
BUNDLE: 1 | |
# - name: Release in local repo | |
# if: matrix.os == 'ubuntu-latest' | |
# run: pnpm run release:local | |
- name: Run tests | |
run: pnpm run test | |
env: | |
BUNDLE: 1 | |
- name: Deploy CLI locally | |
run: pnpm deploy --prod --filter=./packages/cli ./bati-cli | |
- name: Archive Bati CLI | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bati-cli-${{ matrix.os }}-${{ matrix.node }} | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
include-hidden-files: true | |
path: ./bati-cli/dist/* | |
- name: Deploy tests locally | |
run: pnpm deploy --prod --filter=./packages/tests ./bati-tests | |
- name: Archive Bati tests | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bati-tests-${{ matrix.os }}-${{ matrix.node }} | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
include-hidden-files: true | |
path: ./bati-tests/dist/* | |
- name: Pack tests-utils | |
run: pnpm pack | |
working-directory: ./packages/tests-utils | |
- name: Archive tests-utils | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tests-utils-${{ matrix.os }}-${{ matrix.node }} | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
include-hidden-files: true | |
path: ./packages/tests-utils/batijs-tests-utils-*.tgz | |
- name: Archive tests files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: tests-files-${{ matrix.os }}-${{ matrix.node }} | |
if-no-files-found: error | |
retention-days: 1 | |
overwrite: true | |
include-hidden-files: true | |
path: ./packages/tests/tests/* | |
- name: List e2e tests | |
id: list-e2e | |
run: pnpm run test:e2e list | |
env: | |
TEST_AUTH0_CLIENT_ID: ${{ secrets.TEST_AUTH0_CLIENT_ID }} | |
TEST_AUTH0_ISSUER_BASE_URL: ${{ secrets.TEST_AUTH0_ISSUER_BASE_URL }} | |
TEST_FIREBASE_ACCOUNT: ${{ secrets.TEST_FIREBASE_ACCOUNT }} | |
TEST_FIREBASE_USER_UID: ${{ secrets.TEST_FIREBASE_USER_UID }} | |
TEST_GITHUB_CLIENT_ID: ${{ secrets.TEST_GITHUB_CLIENT_ID }} | |
TEST_GITHUB_CLIENT_SECRET: ${{ secrets.TEST_GITHUB_CLIENT_SECRET }} | |
outputs: | |
test-matrix: ${{ steps.list-e2e.outputs.test-matrix }} | |
# - name: Archive summary | |
# if: matrix.os == 'ubuntu-latest' | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ runner.os }}-${{ matrix.node }}-summary | |
# path: | | |
# ${{ runner.temp }}/bati/.turbo/runs/*.json | |
generated: | |
needs: monorepo | |
strategy: | |
fail-fast: false | |
matrix: | |
test-matrix: ${{ fromJson(needs.monorepo.outputs.test-matrix) }} | |
name: Trigger e2e tests | |
uses: ./.github/workflows/reusable.yml | |
with: | |
# runs-on: ${{ matrix.os }} | |
runs-on: ubuntu-latest | |
# node: ${{ matrix.node }} | |
node: 20 | |
flags: ${{ matrix.test-matrix[0] }} | |
test-files: ${{ matrix.test-matrix[1] }} | |