From b803bfb0a5b1df1fb493d9403b0d92f36be8de44 Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Tue, 17 Sep 2024 11:10:21 +0300 Subject: [PATCH 1/2] (chore) Set turbo-token for incremental remote caching --- .github/workflows/e2e.yml | 35 ++++++++---- .github/workflows/node.js.yml | 104 +++++++++++++++++++--------------- .github/workflows/size.yml | 2 +- 3 files changed, 82 insertions(+), 59 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f8efaa2..bdf154e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -10,7 +10,7 @@ on: env: TURBO_API: 'http://127.0.0.1:9080' - TURBO_TOKEN: ${{ secrets.TURBO_SERVER_TOKEN }} + TURBO_TOKEN: 'turbo-token' TURBO_TEAM: ${{ github.repository_owner }} jobs: @@ -18,24 +18,30 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - name: Checkout repo + - name: ๐Ÿ“ฅ Checkout repo uses: actions/checkout@v4 - - name: Copy test environment variables + - name: ๐Ÿ“‹ Copy test environment variables run: cp example.env .env - - name: Setup node + - name: ๐Ÿ› ๏ธ Setup node uses: actions/setup-node@v4 with: node-version: 18 +<<<<<<< Updated upstream - name: Cache dependencies id: cache-dependencies +======= + - name: ๐Ÿ’พ Cache dependencies + id: cache +>>>>>>> Stashed changes uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} +<<<<<<< Updated upstream - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: yarn install --immutable @@ -53,32 +59,39 @@ jobs: key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} - name: Install Playwright Browsers +======= + - name: ๐Ÿ“ฆ Install dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: yarn install --immutable + + - name: ๐ŸŽญ Install Playwright Browsers +>>>>>>> Stashed changes run: npx playwright install chromium --with-deps if: steps.playwright-cache.outputs.cache-hit != 'true' - - name: Setup local cache server for Turborepo + - name: ๐Ÿš€ Setup local cache server for Turborepo uses: felixmosh/turborepo-gh-artifacts@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} server-token: ${{ env.TURBO_TOKEN }} - - name: Build app + - name: ๐Ÿ—๏ธ Build app run: yarn turbo run build --color - - name: Run dev server + - name: ๐Ÿ–ฅ๏ธ Run dev server run: bash e2e/support/github/run-e2e-docker-env.sh - - name: Wait for OpenMRS instance to start + - name: โณ Wait for OpenMRS instance to start run: while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost:8080/openmrs/login.htm)" != "200" ]]; do sleep 10; done - - name: Run E2E tests + - name: ๐Ÿงช Run E2E tests run: yarn playwright test - - name: Stop dev server + - name: ๐Ÿ›‘ Stop dev server if: '!cancelled()' run: docker stop $(docker ps -a -q) - - name: Upload Report + - name: ๐Ÿ“ค Upload Report uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 52194c4..d68e4ba 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -10,48 +10,45 @@ on: - created env: - ESM_NAME: "@openmrs/esm-form-builder-app" - JS_NAME: "openmrs-esm-form-builder-app.js" + TURBO_API: 'http://127.0.0.1:9080' + TURBO_TOKEN: 'turbo-token' + TURBO_TEAM: ${{ github.repository_owner }} jobs: build: runs-on: ubuntu-latest - env: - TURBO_API: 'http://127.0.0.1:9080' - TURBO_TOKEN: ${{ secrets.TURBO_SERVER_TOKEN }} - TURBO_TEAM: ${{ github.repository_owner }} steps: - uses: actions/checkout@v4 - - name: Setup Node.js + - name: ๐Ÿ› ๏ธ Setup Node.js uses: actions/setup-node@v4 with: node-version: "18" - - name: Cache dependencies + - name: ๐Ÿ’พ Cache dependencies id: cache uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - name: Install dependencies + - name: ๐Ÿ“ฆ Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: yarn install --immutable - - name: Setup local cache server for Turborepo + - name: ๐Ÿš€ Setup local cache server for Turborepo uses: felixmosh/turborepo-gh-artifacts@v3 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - server-token: ${{ secrets.TURBO_SERVER_TOKEN }} + server-token: ${{ env.TURBO_TOKEN }} - - name: Run tests, lint and typechecking + - name: ๐Ÿงช Run tests, lint and typechecking run: yarn verify - - name: Run build + - name: ๐Ÿ—๏ธ Run build run: yarn turbo run build - - name: Upload Artifacts + - name: ๐Ÿ“ค Upload Artifacts uses: actions/upload-artifact@v4 with: name: dist @@ -68,37 +65,44 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Setup Node.js + - name: ๐Ÿ› ๏ธ Setup Node.js uses: actions/setup-node@v4 with: node-version: "18" - - name: Cache dependencies + - name: ๐Ÿ’พ Cache dependencies id: cache uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - name: Install dependencies + - name: ๐Ÿ“ฆ Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: yarn install --immutable - - name: Version + - name: ๐Ÿš€ Setup local cache server for Turborepo + uses: felixmosh/turborepo-gh-artifacts@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ env.TURBO_TOKEN }} + + - name: ๐Ÿท๏ธ Version run: yarn version "$(node -e "console.log(require('semver').inc(require('./package.json').version, 'patch'))")-pre.${{ github.run_number }}" - - name: Build + - name: ๐Ÿ—๏ธ Build run: yarn turbo run build + - name: ๐Ÿ”ง Configure Git + run: git config user.email "info@openmrs.org" && git config user.name "OpenMRS CI" + - name: ๐Ÿ’พ Commit changes + run: git add . && git commit -m "Prerelease version" --no-verify - - run: git config user.email "info@openmrs.org" && git config user.name "OpenMRS CI" - - run: git add . && git commit -m "Prerelease version" --no-verify - - - name: Pre-release + - name: ๐Ÿš€ Pre-release run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public --tag next env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - name: Upload Artifacts + - name: ๐Ÿ“ค Upload Artifacts uses: actions/upload-artifact@v4 with: name: dist @@ -106,21 +110,6 @@ jobs: dist overwrite: true - deploy_form_builder: - runs-on: ubuntu-latest - - needs: pre_release - - if: ${{ github.event_name == 'push' }} - - steps: - - name: Trigger RefApp Build - uses: fjogeleit/http-request-action@v1 - with: - url: https://ci.openmrs.org/rest/api/latest/queue/O3-BF - method: "POST" - customHeaders: '{ "Authorization": "Bearer ${{ secrets.BAMBOO_TOKEN }}" }' - release: runs-on: ubuntu-latest @@ -130,35 +119,56 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Download Artifacts - + - name: ๐Ÿ“ฅ Download Artifacts uses: actions/download-artifact@v4 - - name: Use Node.js + - name: ๐Ÿ› ๏ธ Use Node.js uses: actions/setup-node@v4 with: node-version: "18" - - name: Cache dependencies + - name: ๐Ÿ’พ Cache dependencies id: cache uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} - - name: Install dependencies + - name: ๐Ÿ“ฆ Install dependencies if: steps.cache.outputs.cache-hit != 'true' run: yarn install --immutable - - name: Build + - name: ๐Ÿš€ Setup local cache server for Turborepo + uses: felixmosh/turborepo-gh-artifacts@v3 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + server-token: ${{ env.TURBO_TOKEN }} + + - name: ๐Ÿ—๏ธ Build run: yarn turbo run build - - run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public + - name: ๐Ÿš€ Publish to NPM + run: yarn config set npmAuthToken "${NODE_AUTH_TOKEN}" && yarn npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - - name: Upload Artifacts + - name: ๐Ÿ“ค Upload Artifacts uses: actions/upload-artifact@v4 with: name: dist path: | dist overwrite: true + + deploy_form_builder: + runs-on: ubuntu-latest + + needs: pre_release + + if: ${{ github.event_name == 'push' }} + + steps: + - name: ๐Ÿš€ Trigger RefApp Build + uses: fjogeleit/http-request-action@v1 + with: + url: https://ci.openmrs.org/rest/api/latest/queue/O3-BF + method: "POST" + customHeaders: '{ "Authorization": "Bearer ${{ secrets.BAMBOO_TOKEN }}" }' diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml index 175ed5b..701481d 100644 --- a/.github/workflows/size.yml +++ b/.github/workflows/size.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Compute bundle size differences + - name: ๐Ÿ“ Compute bundle size differences uses: preactjs/compressed-size-action@v2 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From 22d7ff755ca803c79bf15007648dc0aa84f0bcab Mon Sep 17 00:00:00 2001 From: Dennis Kigen Date: Tue, 17 Sep 2024 11:16:07 +0300 Subject: [PATCH 2/2] (chore) Fixup e2e workflow --- .github/workflows/e2e.yml | 25 ++++++------------------- .github/workflows/node.js.yml | 2 +- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index bdf154e..8a80ba6 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -29,28 +29,22 @@ jobs: with: node-version: 18 -<<<<<<< Updated upstream - - name: Cache dependencies - id: cache-dependencies -======= - name: ๐Ÿ’พ Cache dependencies - id: cache ->>>>>>> Stashed changes + id: cache-dependencies uses: actions/cache@v4 with: path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} -<<<<<<< Updated upstream - - name: Install dependencies + - name: ๐Ÿ“ฆ Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: yarn install --immutable - - name: Get installed Playwright version + - name: ๐Ÿ” Get installed Playwright version id: playwright-version run: echo "PLAYWRIGHT_VERSION=$(grep '@playwright/test@' yarn.lock | sed -n 's/.*npm:\([^":]*\).*/\1/p' | head -n 1)" >> $GITHUB_ENV - - name: Cache Playwright binaries + - name: ๐Ÿ’พ Cache Playwright binaries id: playwright-cache uses: actions/cache@v4 with: @@ -58,14 +52,7 @@ jobs: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} - - name: Install Playwright Browsers -======= - - name: ๐Ÿ“ฆ Install dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: yarn install --immutable - - name: ๐ŸŽญ Install Playwright Browsers ->>>>>>> Stashed changes run: npx playwright install chromium --with-deps if: steps.playwright-cache.outputs.cache-hit != 'true' @@ -100,13 +87,13 @@ jobs: retention-days: 30 overwrite: true - - name: Capture Server Logs + - name: ๐Ÿ“ Capture Server Logs if: always() uses: jwalton/gh-docker-logs@v2 with: dest: './logs' - - name: Upload Logs as Artifact + - name: ๐Ÿ“ฆ Upload Logs as Artifact uses: actions/upload-artifact@v4 if: always() with: diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index d68e4ba..daf2a57 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -42,7 +42,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} server-token: ${{ env.TURBO_TOKEN }} - - name: ๐Ÿงช Run tests, lint and typechecking + - name: ๐Ÿงช Run tests, lint and type checks run: yarn verify - name: ๐Ÿ—๏ธ Run build