diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml deleted file mode 100644 index cb1b5be44f4..00000000000 --- a/.github/workflows/bootstrap.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: CI - -on: - push: - branches: [main, develop, release, yeet, private, beard, juice, gome, neo, arkeo, jib] - pull_request: - branches: [main, develop, release, yeet, private] - -jobs: - install-and-cache: - name: Install and Cache - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v4 - with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: ${{ runner.os }}-node- - - - name: Yarn Install - run: yarn install --immutable - - call-pr-workflow: - name: Call - uses: ./.github/workflows/pr.yml - needs: [install-and-cache] - - call-cloudflare-workflow: - name: Call - uses: ./.github/workflows/cloudflare.yml - secrets: inherit # pass org/repo secrets to the called workflow - needs: [install-and-cache] diff --git a/.github/workflows/cloudflare.yml b/.github/workflows/ci.yml similarity index 61% rename from .github/workflows/cloudflare.yml rename to .github/workflows/ci.yml index 6d27838d978..652edc6172c 100644 --- a/.github/workflows/cloudflare.yml +++ b/.github/workflows/ci.yml @@ -1,57 +1,106 @@ +name: CI + on: - workflow_call: + push: + branches: [main, develop, release, yeet, private, beard, juice, gome, neo, arkeo, jib] + pull_request: + branches: [main, develop, release, yeet, private] jobs: + static: + name: Static + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: OpenJDK + uses: actions/setup-java@v4 + with: + distribution: 'microsoft' + java-version: '11' + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + + - name: Cache node_modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: ${{ runner.os }}-node- + + - name: Yarn Install + run: yarn install --immutable + + - name: Commitlint PR Title + if: ${{ github.event_name == 'pull_request' }} + env: + TITLE: ${{ github.event.pull_request.title }} + run: printf '%s' "$TITLE" | npx commitlint + + - name: Build Packages + run: yarn build:packages + + - name: Cache ESLint + uses: actions/cache@v4 + with: + path: .eslintcache + key: ${{ runner.os }}-eslint-${{ hashFiles('**/yarn.lock') }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-eslint-${{ hashFiles('**/yarn.lock') }}- + ${{ runner.os }}-eslint- + + - name: Cache TypeScript Build Info + uses: actions/cache@v4 + with: + path: tsconfig.tsbuildinfo + key: ${{ runner.os }}-tsbuildinfo-${{ hashFiles('src/**/*.ts', 'src/**/*.tsx') }} + restore-keys: ${{ runner.os }}-tsbuildinfo- + + - name: Lint, Type Check & Test + run: yarn concurrently "yarn lint" "yarn type-check" "yarn test" + deploy: + name: Deploy + if: contains(fromJSON('["develop", "release", "yeet", "main", "private", "beard", "juice", "gome", "neo", "arkeo", "jib"]'), github.event_name == 'pull_request' && github.head_ref || github.ref_name) + runs-on: ubuntu-latest env: - # https://docs.github.com/en/actions/learn-github-actions/contexts#example-contents-of-the-github-context - PROJECT_NAME: web # cloudflare bug? our project name/alias is web-29e but wrangler wants just "web" + PROJECT_NAME: web CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} FLEEK_TOKEN: ${{ secrets.FLEEK_TOKEN }} FLEEK_PROJECT_ID: ${{ secrets.FLEEK_PROJECT_ID }} - # https://github.com/actions/runner/issues/409#issuecomment-752775072 - # Github Actions DSL expression fuckery to make a ternary - # syntax is if condition && true || false - # i.e. if it's a pull request, use the head ref, otherwise use the ref name - # so ultimately we only run this workflow against the whitelisted branches - if: contains(fromJSON('["develop", "release", "yeet", "main", "private", "beard", "juice", "gome", "neo", "arkeo", "jib"]'), github.event_name == 'pull_request' && github.head_ref || github.ref_name) - runs-on: ubuntu-latest - name: Build steps: - name: Checkout uses: actions/checkout@v4 with: - # Fetch all history and tags for version extraction via git describe fetch-depth: 0 + - name: Setup Environment (PR) if: ${{ github.event_name == 'pull_request' }} - # github actions run in the context of a special magical merge commit between the head of the PR - # and the base branch. this means that the commit hash is not the same as the head of the PR. - # we have to conditionally grab the head of the PR and truncate it to 7 characters. - # in a `pull_request`` event trigger, base_ref is target branch name, head_ref is current run: | echo "COMMIT_SHORT_HASH=`echo ${{ github.event.pull_request.head.sha }} | cut -c1-7`" >> ${GITHUB_ENV} echo "CURRENT_BRANCH_NAME=${{ github.head_ref }}" >> ${GITHUB_ENV} - # in a `pull` event trigger, e.g. yoloing to develop or main, GITHUB_SHA is the head commit - # of the branch and we can use that directly. - # ref_name is the name of the branch, e.g. develop, main, etc. + - name: Setup Environment (Push) if: ${{ github.event_name == 'push' }} run: | echo "COMMIT_SHORT_HASH=`echo ${GITHUB_SHA} | cut -c1-7`" >> ${GITHUB_ENV} echo "CURRENT_BRANCH_NAME=${{ github.ref_name }}" >> ${GITHUB_ENV} + - name: Extract Version run: | - # Get version from the closest git tag (e.g., "v1.977.0" -> "1.977.0") - # Tags are created by release-please when PRs are merged to main - # Fallback to commit hash if no tags exist TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") if [[ "$TAG" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then echo "version=${BASH_REMATCH[1]}" >> ${GITHUB_ENV} else echo "version=${{ env.COMMIT_SHORT_HASH }}" >> ${GITHUB_ENV} fi + - name: Determine Build Mode run: | if [[ "${{ github.ref_name }}" == "main" || "${{ github.ref_name }}" == "release" || "${{ github.head_ref }}" == "main" || "${{ github.head_ref }}" == "release" ]]; then @@ -61,30 +110,39 @@ jobs: else echo "BUILD_MODE=development" >> ${GITHUB_ENV} fi + - name: Debug GitHub Context env: { CONTENT : "${{ toJson(github) }}" } run: "echo $CONTENT" + + - name: OpenJDK + uses: actions/setup-java@v4 + with: + distribution: 'microsoft' + java-version: '11' + - name: Setup Node uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'yarn' + - name: Cache node_modules uses: actions/cache@v4 with: path: node_modules key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} restore-keys: ${{ runner.os }}-node- + - name: Yarn Install run: yarn install --immutable + - name: Build Web run: MODE=${{ env.BUILD_MODE }} DEPLOY=true VITE_VERSION=${{ env.version }} yarn build:web - # a poor mans extension of cloudflare/pages-action@1 https://github.com/cloudflare/pages-action/blob/main/src/index.ts - # passing more params directly to wrangler to control commit hash and message - # https://developers.cloudflare.com/workers/wrangler/commands/#publish-1 + - name: Deploy run: npx -y wrangler@2 pages publish build --project-name="${{ env.PROJECT_NAME }}" --branch="${{ env.CURRENT_BRANCH_NAME }}" --commit-hash="${{ env.COMMIT_SHORT_HASH }}" --commit-message="${{ env.CURRENT_BRANCH_NAME }}-${{ env.COMMIT_SHORT_HASH }}" - # deploy main branch to fleek.xyz alpha environment + - name: Deploy to Fleek if: contains(fromJSON('["main"]'), github.event_name == 'pull_request' && github.head_ref || github.ref_name) run: npm i -g @fleek-platform/cli && fleek sites deploy diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml deleted file mode 100644 index f5c7d894949..00000000000 --- a/.github/workflows/pr.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Commitlint, Lint, Type Check, Test & Build - -on: - workflow_call: - -jobs: - static: - name: Static - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: OpenJDK - uses: actions/setup-java@v4 - with: - distribution: 'microsoft' - java-version: '11' - - - name: Setup Node - uses: actions/setup-node@v4 - with: - node-version-file: '.nvmrc' - cache: 'yarn' - - - name: Cache node_modules - uses: actions/cache@v4 - with: - path: node_modules - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: ${{ runner.os }}-node- - - - name: Yarn Install - run: yarn install --immutable - - # needs to run after install - - name: Commitlint PR Title - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-contexts - # only commitlint on PRs - pull_request.title not available in merge_group (merge queue) - # https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#merge_group - # once a PR is in the merge queue, its title has already been commitlint'd - if: ${{ github.event_name == 'pull_request' }} - env: - TITLE: ${{ github.event.pull_request.title }} - run: printf '%s' "$TITLE" | npx commitlint - - - name: Build Packages - run: yarn build:packages - - - name: Lint - run: yarn lint - - - name: Type Check - run: yarn type-check - - - name: Test - run: yarn test diff --git a/package.json b/package.json index f41aea1e3dd..1ddc5d02a9b 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,10 @@ "postinstall": "git config --local include.path '.gitconfig'", "release": "yarn tsx ./scripts/release.ts", "scrape-walletconnect-dapps": "yarn tsx ./scripts/scrapeWalletConnectRegistry.ts", - "test": "yarn test:packages && yarn test:web", - "test:web": "yarn vitest run -c vitest-web.config.mts && yarn vitest run -c vitest-side-effects.config.mts", + "test": "yarn concurrently \"yarn test:packages\" \"yarn test:web:main\" \"yarn test:web:side-effects\"", + "test:web": "yarn test:web:main && yarn test:web:side-effects", + "test:web:main": "yarn vitest run -c vitest-web.config.mts", + "test:web:side-effects": "yarn vitest run -c vitest-side-effects.config.mts", "test:packages": "yarn vitest run -c vitest-packages.config.mts", "translations:count-words-invalidate-since": "yarn tsx ./scripts/translations/countWordsInvalidateSince.ts", "translations:update-path": "yarn tsx ./scripts/translations/updateTranslationPath.ts", diff --git a/tsconfig.json b/tsconfig.json index 555692f7872..49c131936f8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,6 +5,7 @@ "lib": ["dom", "dom.iterable", "esnext"], "types": ["vite/client"], "skipLibCheck": true, + "incremental": true, "noEmit": true, /* Type Checking */ diff --git a/vitest.config.mts b/vitest.config.mts index 979c2de6f5f..c3056ef348d 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -8,14 +8,6 @@ export default defineConfig(() => { test: { setupFiles: ['src/setupVitest'], clearMocks: true, - poolOptions: { - threads: { - singleThread: true, - }, - forks: { - isolate: false, - }, - }, }, } })