From c6e861896536e2fab4fc6f2613ad49dc22781dd8 Mon Sep 17 00:00:00 2001 From: roguisharcanetrickster Date: Thu, 28 May 2026 15:17:30 +0700 Subject: [PATCH] add act script --- .github/workflows/e2e-test_local.yml | 115 +++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 116 insertions(+) create mode 100644 .github/workflows/e2e-test_local.yml diff --git a/.github/workflows/e2e-test_local.yml b/.github/workflows/e2e-test_local.yml new file mode 100644 index 0000000..94e2214 --- /dev/null +++ b/.github/workflows/e2e-test_local.yml @@ -0,0 +1,115 @@ +# do everything the e2e-test.yml does, but faster and locally +name: E2E Tests & Update Web Service +on: + workflow_call: + inputs: + ref: + type: string + default: ${{ github.ref }} + app_id: + description: GitHub App ID for Auth (or client ID) + type: string + required: true + secrets: + app_secret: + description: GitHub App client secret for Auth + required: true + +jobs: + e2e-tests: + name: Test + runs-on: ubuntu-latest + env: + CYPRESS_RESPONSE_TIMEOUT: 200000 + CYPRESS_DEFAULT_COMMAND_TIMEOUT: 30000 + CYPRESS_RETRIES: 2 + strategy: + matrix: + include: + - branch: develop + webpack: dev + - branch: master + webpack: update + steps: + - uses: actions/checkout@v6 + if: ${{ !env.ACT }} + with: + path: plugins/plugin_ABDesigner + ref: ${{ inputs.ref }} + - name: Local act mode + if: ${{ env.ACT }} + run: echo "ACT mode - skipping external-repo e2e flow." + - name: Generate a token + if: ${{ !env.ACT }} + id: generate-token + uses: actions/create-github-app-token@v3 + with: + app-id: ${{ inputs.app_id }} + private-key: ${{ secrets.app_secret }} + repositories: ab_service_web + + - uses: actions/checkout@v6 + if: ${{ !env.ACT }} + with: + path: web + repository: CruGlobal/ab_service_web + token: ${{ steps.generate-token.outputs.token }} + ref: ${{ matrix.branch }} + + - run: npm i + if: ${{ !env.ACT }} + working-directory: plugins/plugin_ABDesigner + - name: Webpack + if: ${{ !env.ACT }} + run: npm run build:${{ matrix.webpack }} + working-directory: plugins/plugin_ABDesigner + + # webpack expects the folder to be called "web" ab-install action expects "ab_service_web" + - run: mv web ab_service_web + if: ${{ !env.ACT }} + - uses: CruGlobal/ab-install-action@v1 + if: ${{ !env.ACT }} + with: + port: 8080 + folder: ab + repository: CruGlobal/ab_service_web + + - name: Check out kitchen-sink tests + if: ${{ !env.ACT }} + uses: actions/checkout@v6 + with: + repository: CruGlobal/kitchensink_app + path: ab/test/e2e/cypress/e2e/kitchensink_app + + # These next steps are to save our ablogs to file + - run: npm install pm2@latest -g + if: ${{ !env.ACT }} + - name: Save Logs + if: ${{ !env.ACT }} + run: pm2 start ./logs.js -- --toFile logs/ABServices.log + working-directory: ./ab + + # Skipping the wait step. Cypress has a bit of wait time built in. + # - name: Wait for AB + # if: false + # uses: ifaxity/wait-on-action@v1.1.0 + # with: + # resource: http://localhost:8080 + # timeout: 300000 + + - name: Run Cypress Tests + if: ${{ !env.ACT }} + run: npm run test:e2e:ab-designer -- --browser chrome + working-directory: ./ab + + - uses: actions/upload-artifact@v6 + if: ${{ failure() && !env.ACT }} + with: + name: cypress-screenshots + path: ./ab/test/e2e/cypress/screenshots + + - uses: actions/upload-artifact@v6 + if: ${{ failure() && !env.ACT }} + with: + name: ABServices.log + path: ./ab/logs/ABServices.log diff --git a/package.json b/package.json index e6e6cf1..9eb1631 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build:dev": "webpack-cli --config webpack.dev.js", "build:update": "webpack-cli --config webpack.prod.js", "test": "mocha --config test/.mocharc.js test/**/*.test.js test/**/**/*.test.js", + "act": "act -W .github/workflows/e2e-test_local.yml -j e2e-tests --container-architecture linux/amd64", "watch": "webpack-cli --config webpack.dev.js --watch --progress", "break": "node --inspect-brk=9229 ./node_modules/.bin/webpack-cli --watch --progress" },