From 61f44046fb34f3be9a6dc63d0788f40f0fbeccaf Mon Sep 17 00:00:00 2001 From: Manolo Carrasco Date: Fri, 17 Jan 2025 09:39:35 +0100 Subject: [PATCH] rename workflow --- .github/workflows/a.yml | 39 ---------------- .github/workflows/pit.yml | 75 ++++++++++++++++++++++++++++++ scripts/pit/its/cc-install-apps.js | 8 ++-- scripts/pit/its/cc-setup.js | 8 ++-- scripts/pit/lib/lib-cc.sh | 2 + scripts/pit/run.sh | 4 ++ 6 files changed, 91 insertions(+), 45 deletions(-) delete mode 100644 .github/workflows/a.yml create mode 100644 .github/workflows/pit.yml diff --git a/.github/workflows/a.yml b/.github/workflows/a.yml deleted file mode 100644 index e6ca4e91..00000000 --- a/.github/workflows/a.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Run PiT -on: - workflow_dispatch: - push: -jobs: - run: - runs-on: ubuntu-latest - services: - docker: - image: docker:dind - options: --privileged --shm-size=2g - steps: - - name: Check out branch - uses: actions/checkout@v4 - - if: ${{ env.ACT }} - name: ACT - install dependencies - run: | - echo "export PATH='$PATH'" > path.sh - apt-get update - apt-get install -y vim iputils-ping sudo unzip wget jq curl - - uses: actions/setup-node@v4 - with: - node-version: '18' - - name: Set up Helm - uses: azure/setup-helm@v3.5 - - name: Create k8s Kind Cluster - uses: helm/kind-action@v1 - with: - install_only: false - - name: Run PiT - env: - CC_KEY: ${{ secrets.CC_KEY }} - CC_CERT: ${{ secrets.CC_CERT }} - run: | - set - ./scripts/pit/run.sh --starter=control-center - - - diff --git a/.github/workflows/pit.yml b/.github/workflows/pit.yml new file mode 100644 index 00000000..654af0d7 --- /dev/null +++ b/.github/workflows/pit.yml @@ -0,0 +1,75 @@ +name: Run PiT +on: + workflow_dispatch: + inputs: + version: + description: 'Version' + required: false + type: string + starters: + description: 'Starters to run, separated by comma' + required: true + default: 'control-center' + type: string + skipcurrent: + description: 'Skip running tests in current version' + required: false + type: boolean + default: false + skipdev: + description: 'Skip running tests in dev mode' + required: false + type: boolean + default: false + debug: + description: 'Be verbose when running PiT steps' + required: false + type: boolean + default: false + push: +jobs: + run: + runs-on: ubuntu-latest + services: + docker: + image: docker:dind + options: --privileged --shm-size=2g + steps: + - name: Check out branch + uses: actions/checkout@v4 + - if: ${{ env.ACT }} + name: ACT - install dependencies + run: | + echo "export PATH='$PATH'" > path.sh + apt-get update + apt-get install -y vim iputils-ping sudo unzip wget jq curl + - uses: actions/setup-node@v4 + with: + node-version: '18' + - name: Set up Helm + uses: azure/setup-helm@v3.5 + - name: Create k8s Kind Cluster + uses: helm/kind-action@v1 + with: + install_only: false + - name: Run PiT + env: + CC_KEY: ${{ secrets.CC_KEY }} + CC_CERT: ${{ secrets.CC_CERT }} + run: | + [ -n "${{ inputs.skipcurrent }}" ] && A="$A --skip-current" + [ -n "${{ inputs.skipdev }}" ] && A="$A --skip-dev" + [ -n "${{ inputs.debug }}" ] && A="$A --debug" + [ -n "${{ inputs.version }}" ] && A="$A --version=${{ inputs.version }}" + [ -n "${{ inputs.starters }}" ] && A="$A --starters=${{ inputs.starters }}" || A="$A --starters=control-center" + ./scripts/pit/run.sh $A + - if: ${{ always()}} + uses: actions/upload-artifact@v4 + with: + name: outputs + path: tmp/**/*.out + if-no-files-found: ignore + retention-days: 2 + + + diff --git a/scripts/pit/its/cc-install-apps.js b/scripts/pit/its/cc-install-apps.js index 7f0b53ea..9c01ba4b 100644 --- a/scripts/pit/its/cc-install-apps.js +++ b/scripts/pit/its/cc-install-apps.js @@ -34,12 +34,14 @@ const log = s => process.stderr.write(` ${s}`); const screenshots = "screenshots.out" let sscount = 0; async function takeScreenshot(page, name) { - const path = `${screenshots}/${++sscount}-${name}.png`; + var scr = path.basename(__filename); + const file = `${screenshots}/${scr}-${++sscount}-${name}.png`; await page.waitForTimeout(1000); - await page.screenshot({ path }); - log(`Screenshot taken: ${path}\n`); + await page.screenshot({ path: file }); + log(`Screenshot taken: ${file}\n`); } + (async () => { const browser = await chromium.launch({ headless: headless, diff --git a/scripts/pit/its/cc-setup.js b/scripts/pit/its/cc-setup.js index 2659bc8c..8c17ea44 100644 --- a/scripts/pit/its/cc-setup.js +++ b/scripts/pit/its/cc-setup.js @@ -2,6 +2,7 @@ const {chromium} = require('playwright'); const { expect } = require('@playwright/test'); const { exec } = require('child_process'); const promisify = require('util').promisify; +const path = require('path'); const log = s => process.stderr.write(` ${s}`); const run = async cmd => (await promisify(exec)(cmd)).stdout; @@ -37,10 +38,11 @@ if (!email) { const screenshots = "screenshots.out" let sscount = 0; async function takeScreenshot(page, name) { - const path = `${screenshots}/${++sscount}-${name}.png`; + var scr = path.basename(__filename); + const file = `${screenshots}/${scr}-${++sscount}-${name}.png`; await page.waitForTimeout(1000); - await page.screenshot({ path }); - log(`Screenshot taken: ${path}\n`); + await page.screenshot({ path: file }); + log(`Screenshot taken: ${file}\n`); } (async () => { diff --git a/scripts/pit/lib/lib-cc.sh b/scripts/pit/lib/lib-cc.sh index 0add05e5..25e89009 100644 --- a/scripts/pit/lib/lib-cc.sh +++ b/scripts/pit/lib/lib-cc.sh @@ -164,9 +164,11 @@ runControlCenter() { tmp_email=`kubectl get secret control-center-user -o go-template="{{ .data.email | base64decode | println }}"` computeTemporaryPassword installTls + set -x forwardIngress || return 1 runPwTests || return 1 err=$? + set +x if [ -z "$KEEPCC" ]; then stopForwardIngress deleteCluster diff --git a/scripts/pit/run.sh b/scripts/pit/run.sh index 57fe95e9..d53953c8 100755 --- a/scripts/pit/run.sh +++ b/scripts/pit/run.sh @@ -101,7 +101,11 @@ main() { ## Run demos (proper starters in github) for i in $demos; do if [ $i = control-center ]; then + mkdir -p tmp/$i && cd tmp/$i run runControlCenter start + pwd + find . + cd "$pwd" continue elif expr "$i" : '.*_jdk' >/dev/null; then _jdk=`echo "$i" | sed -e 's|.*_jdk||'`