diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..31930f9 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,170 @@ +name: Lint modules + +on: + pull_request: + branches: [ master ] + paths-ignore: + - "**/README.md" + push: + paths-ignore: + - "**/README.md" + workflow_dispatch: + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + github_token: ${{ github.token }} + paths_ignore: '["**/README.md"]' + do_not_skip: '["push"]' + + detect-changes: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + outputs: + changed-modules: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + payments: + - 'pos-module-payments/**' + user: + - 'pos-module-user/**' + chat: + - 'pos-module-chat/**' + common-styling: + - 'pos-module-common-styling/**' + tests: + - 'pos-module-tests/**' + core: + - 'pos-module-core/**' + oauth-facebook: + - 'pos-module-oauth-facebook/**' + oauth-github: + - 'pos-module-oauth-github/**' + oauth-google: + - 'pos-module-oauth-google/**' + openai: + - 'pos-module-openai/**' + reports: + - 'pos-module-reports/**' + data-export-api: + - 'pos-module-data-export-api/**' + payments-stripe: + - 'pos-module-payments-stripe/**' + payments-example-gateway: + - 'pos-module-payments-example-gateway/**' + + - name: Set matrix for changed modules + id: set-matrix + run: | + # Extract module names where filter output is "true" + modules=$(echo '${{ toJSON(steps.filter.outputs) }}' | jq -c '[to_entries[] | select(.value == "true") | .key]') + + echo "matrix=$modules" >> $GITHUB_OUTPUT + echo "Changed modules for linting: $modules" + + lint-platformos-check: + needs: detect-changes + if: needs.detect-changes.outputs.changed-modules != '[]' + runs-on: ubuntu-latest + strategy: + matrix: + module: ${{ fromJSON(needs.detect-changes.outputs.changed-modules) }} + fail-fast: false + env: + CI: true + PLATFORMOS_CHECK_DEBUG: true + DOCKER_WORKSPACE: ${{ github.workspace }}/pos-module-${{ matrix.module }} + LOGS_DIR: ${{ github.workspace }}/pos-module-${{ matrix.module }}/logs + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up logs directory + run: | + mkdir -p ${{ env.LOGS_DIR }} + chmod -R 777 ${{ env.LOGS_DIR }} + + - name: Start PlatformOS LSP + id: start_lsp + run: | + docker run -i \ + -v ${{ env.DOCKER_WORKSPACE }}:${{ env.DOCKER_WORKSPACE }} \ + -w ${{ env.DOCKER_WORKSPACE }} \ + -e PLATFORMOS_CHECK_DEBUG=${{ env.PLATFORMOS_CHECK_DEBUG }} \ + -e PLATFORMOS_CHECK_DEBUG_LOG_FILE=${{ env.LOGS_DIR }}/platformos-lsp.log \ + platformos/platformos-lsp:latest + + - name: Run platformos-check + if: steps.start_lsp.outcome == 'success' + id: run_check + run: | + set +e # Disable exit on error + docker run -i \ + -v ${{ env.DOCKER_WORKSPACE }}:${{ env.DOCKER_WORKSPACE }} \ + -w ${{ env.DOCKER_WORKSPACE }} \ + -e PLATFORMOS_CHECK_DEBUG=${{ env.PLATFORMOS_CHECK_DEBUG }} \ + -e PLATFORMOS_CHECK_DEBUG_LOG_FILE=${{ env.LOGS_DIR }}/platformos-check.log \ + platformos/platformos-check:latest -o json > ${{ env.LOGS_DIR }}/platformos-check-raw.json + docker_exit_code=$? + set -e # Re-enable exit on error + + jq . ${{ env.LOGS_DIR }}/platformos-check-raw.json | tee ${{ env.LOGS_DIR }}/platformos-check.json + + exit $docker_exit_code + + - name: Upload logs + if: always() && steps.run_check.outcome != 'skipped' + uses: actions/upload-artifact@v4 + with: + name: platformos_check_logs_${{ matrix.module }}_${{ github.run_id }} + path: | + ${{ env.LOGS_DIR }}/platformos-lsp.log + ${{ env.LOGS_DIR }}/platformos-check.json + ${{ env.LOGS_DIR }}/platformos-check-raw.json + + - name: Generate summary + if: always() && steps.run_check.outcome != 'skipped' + run: | + echo "# PlatformOS Check Summary - ${{ matrix.module }} :checkered_flag:" >> $GITHUB_STEP_SUMMARY + echo "## Result: ${{ steps.run_check.outcome }} ${{ env.RESULT_ICON }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + + if [ -f "${{ env.LOGS_DIR }}/platformos-check.json" ]; then + echo "## Issues Found" >> $GITHUB_STEP_SUMMARY + echo "| File | Line | Column | Severity | Check | Message |" >> $GITHUB_STEP_SUMMARY + echo "|------|------|--------|----------|-------|---------|" >> $GITHUB_STEP_SUMMARY + + # Try to parse and add issues + if jq -r '.[] | .path as $file | .offenses[] | "| \($file) | \(.start_row) | \(.start_column) | \(.severity) | \(.check) | \(.message) |"' ${{ env.LOGS_DIR }}/platformos-check.json >> $GITHUB_STEP_SUMMARY 2>&1; then + echo "Issues table generated successfully" + else + echo "| N/A | N/A | N/A | N/A | N/A | Failed to parse JSON - see logs for details |" >> $GITHUB_STEP_SUMMARY + echo "JSON parse error. File contents:" >> $GITHUB_STEP_SUMMARY + echo '```json' >> $GITHUB_STEP_SUMMARY + cat ${{ env.LOGS_DIR }}/platformos-check.json >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + fi + else + echo "## No output file found" >> $GITHUB_STEP_SUMMARY + echo "Expected location: ${{ env.LOGS_DIR }}/platformos-check.json" >> $GITHUB_STEP_SUMMARY + fi + env: + RESULT_ICON: ${{ steps.run_check.outcome == 'success' && ':white_check_mark:' || ':x:' }} + + - name: Fail job if platformos-check failed + if: always() && steps.run_check.outcome == 'failure' + run: | + echo "platformos-check failed — marking job as failed" + exit 1 diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml new file mode 100644 index 0000000..ffa02f5 --- /dev/null +++ b/.github/workflows/test-e2e.yml @@ -0,0 +1,150 @@ +name: E2E tests +on: + pull_request: + branches: [ master ] + paths-ignore: + - "**/README.md" + push: + paths-ignore: + - "**/README.md" + workflow_dispatch: + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + github_token: ${{ github.token }} + paths_ignore: '["**/README.md"]' + do_not_skip: '["push"]' + + detect-changes: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + outputs: + changed-modules: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + user: + - 'pos-module-user/**' + chat: + - 'pos-module-chat/**' + common-styling: + - 'pos-module-common-styling/**' + + - name: Set matrix for changed modules + id: set-matrix + run: | + # Define module configurations + cat > /tmp/module-config.json << 'EOF' + { + "user": { + "module": "user", + "path": "pos-module-user", + "deploy-script": "rm app/pos-modules.* || true\nsh ./tests/data/seed/seed.sh", + "test-commands": "npm run admin-panel-pw-tests\nnpm run pw-tests" + }, + "chat": { + "module": "chat", + "path": "pos-module-chat", + "deploy-script": "rm app/pos-modules.* || true\nsh ./tests/data/seed/seed.sh", + "test-commands": "npm run pw-tests" + }, + "common-styling": { + "module": "common-styling", + "path": "pos-module-common-styling", + "deploy-script": "pos-cli data clean --include-schema --auto-confirm\npos-cli deploy", + "test-commands": "npm run pw-tests" + } + } + EOF + + # Extract changed modules and map to their configurations + modules=$(echo '${{ toJSON(steps.filter.outputs) }}' | \ + jq -c --slurpfile config /tmp/module-config.json \ + '[to_entries[] | select(.value == "true") | .key as $m | $config[0][$m] | select(. != null)]') + + echo "matrix=$modules" >> $GITHUB_OUTPUT + echo "Changed modules matrix: $modules" + + test-e2e: + needs: detect-changes + if: needs.detect-changes.outputs.changed-modules != '[]' + runs-on: ubuntu-latest + container: ${{ vars.PW_CONTAINER }} + strategy: + matrix: + include: ${{ fromJSON(needs.detect-changes.outputs.changed-modules) }} + max-parallel: 1 + fail-fast: false + timeout-minutes: 60 + env: + CI: true + MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }} + NPM_CONFIG_CACHE: ${{ github.workspace }}/.npm + E2E_TEST_PASSWORD: ${{ secrets.E2E_TEST_PASSWORD }} + HTML_ATTACHMENTS_BASE_URL: ${{ vars.HTML_ATTACHMENTS_BASE_URL }} + TEST_REPORT_MPKIT_URL: ${{ vars.TEST_REPORT_MPKIT_URL }} + TEST_REPORT_MPKIT_TOKEN: ${{ secrets.TEST_REPORT_MPKIT_TOKEN }} + steps: + - name: Reserve CI instance + id: reserve + uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 + with: + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + method: reserve + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} + + - name: Get MPKIT token + id: get-token + uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 + with: + method: get-token + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} + + - uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref || github.ref_name }} + + - uses: actions/setup-node@v4 + with: + node-version: 20.x + + - name: Deploy module + timeout-minutes: 10 + shell: sh + env: + MPKIT_URL: ${{ steps.reserve.outputs.mpkit-url }} + MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }} + working-directory: ${{ matrix.path }} + run: | + set -eu + ${{ matrix.deploy-script }} + + - name: Run Playwright tests + shell: sh + env: + MPKIT_URL: ${{ steps.reserve.outputs.mpkit-url }} + working-directory: ${{ matrix.path }} + run: | + set -eu + ${{ matrix.test-commands }} + + - name: Release CI instance + if: always() + uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 + with: + method: release + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..9be6ffe --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,157 @@ +name: Module tests +on: + # pull_request: + # branches: [ master ] + # paths-ignore: + # - "**/README.md" + # push: + # paths-ignore: + # - "**/README.md" + workflow_dispatch: + +jobs: + pre_job: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + github_token: ${{ github.token }} + paths_ignore: '["**/README.md"]' + do_not_skip: '["push"]' + + detect-changes: + needs: pre_job + if: ${{ needs.pre_job.outputs.should_skip != 'true' }} + runs-on: ubuntu-latest + outputs: + payments: ${{ steps.filter.outputs.payments }} + user: ${{ steps.filter.outputs.user }} + chat: ${{ steps.filter.outputs.chat }} + common-styling: ${{ steps.filter.outputs.common-styling }} + tests: ${{ steps.filter.outputs.tests }} + core: ${{ steps.filter.outputs.core }} + oauth-facebook: ${{ steps.filter.outputs.oauth-facebook }} + oauth-github: ${{ steps.filter.outputs.oauth-github }} + oauth-google: ${{ steps.filter.outputs.oauth-google }} + openai: ${{ steps.filter.outputs.openai }} + reports: ${{ steps.filter.outputs.reports }} + data-export-api: ${{ steps.filter.outputs.data-export-api }} + payments-stripe: ${{ steps.filter.outputs.payments-stripe }} + payments-example-gateway: ${{ steps.filter.outputs.payments-example-gateway }} + steps: + - uses: actions/checkout@v4 + + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + payments: + - 'pos-module-payments/**' + user: + - 'pos-module-user/**' + chat: + - 'pos-module-chat/**' + common-styling: + - 'pos-module-common-styling/**' + tests: + - 'pos-module-tests/**' + core: + - 'pos-module-core/**' + oauth-facebook: + - 'pos-module-oauth-facebook/**' + oauth-github: + - 'pos-module-oauth-github/**' + oauth-google: + - 'pos-module-oauth-google/**' + openai: + - 'pos-module-openai/**' + reports: + - 'pos-module-reports/**' + data-export-api: + - 'pos-module-data-export-api/**' + payments-stripe: + - 'pos-module-payments-stripe/**' + payments-example-gateway: + - 'pos-module-payments-example-gateway/**' + + test-platformos: + needs: detect-changes + if: needs.detect-changes.outputs.user == 'true' + runs-on: ubuntu-latest + container: platformos/pos-cli:latest + strategy: + matrix: + include: + - module: user + path: pos-module-user + deploy-script: | + rm app/pos-modules.* || true + sh ./tests/data/seed/seed.sh + fail-fast: false + timeout-minutes: 20 + env: + CI: true + MPKIT_EMAIL: ${{ secrets.MPKIT_EMAIL }} + steps: + - name: Check if this module changed + id: changed + run: | + MODULE_CHANGED="${{ needs.detect-changes.outputs[matrix.module] }}" + if [ "$MODULE_CHANGED" != "true" ]; then + echo "skip=true" >> $GITHUB_OUTPUT + else + echo "skip=false" >> $GITHUB_OUTPUT + fi + + - name: Reserve CI instance + if: steps.changed.outputs.skip != 'true' + id: reserve + uses: Platform-OS/ci-repository-reserve-instance-url@0.0.9 + with: + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + method: reserve + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} + + - name: Get MPKIT token + if: steps.changed.outputs.skip != 'true' + id: get-token + uses: Platform-OS/ci-repository-reserve-instance-url@mask-token + with: + method: get-token + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} + + - uses: actions/checkout@v4 + if: steps.changed.outputs.skip != 'true' + + - name: Deploy module + if: steps.changed.outputs.skip != 'true' + timeout-minutes: 10 + env: + MPKIT_URL: ${{ steps.reserve.outputs.mpkit-url }} + MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }} + working-directory: ${{ matrix.path }} + run: | + set -eu + ${{ matrix.deploy-script }} + + - name: Run platformOS tests + if: steps.changed.outputs.skip != 'true' + timeout-minutes: 10 + env: + MPKIT_URL: ${{ steps.reserve.outputs.mpkit-url }} + MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }} + working-directory: ${{ matrix.path }} + run: | + pos-cli test run + + - name: Release CI instance + if: always() && steps.changed.outputs.skip != 'true' + uses: Platform-OS/ci-repository-reserve-instance-url@0.0.9 + with: + method: release + repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} + pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} diff --git a/ci-repository-reserve-instance-url/Dockerfile b/ci-repository-reserve-instance-url/Dockerfile deleted file mode 100644 index 25f0701..0000000 --- a/ci-repository-reserve-instance-url/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# Container image that runs your code -FROM alpine:3.15 -MAINTAINER Darek - -RUN apk add --update --no-cache curl jq - -# Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh - -# Code file to execute when the docker container starts up (`entrypoint.sh`) -ENTRYPOINT ["/entrypoint.sh"] diff --git a/ci-repository-reserve-instance-url/README.md b/ci-repository-reserve-instance-url/README.md deleted file mode 100644 index d965a64..0000000 --- a/ci-repository-reserve-instance-url/README.md +++ /dev/null @@ -1,171 +0,0 @@ -# ci-repository-reserve-instance-url - -This repository provides a custom GitHub Action for reserving CI instances, getting authorization tokens from the instances and releasing them. These instances are important for deploying applications and running tests in isolated and consistent environments, which helps avoid conflicts and ensures reliable test results. - -## Why Reserve an Instance? - -Each developer working on a branch triggers tests, and the tests need to run somewhere on platformOS. We need to **reserve an instance** on which the application will be deployed and then the test will be run against it. This avoids conflicts that might arise from running multiple tests simultaneously on the same instance. It also ensures consistency across test runs, making it easier to identify issues. - -GH Actions need to be authorized to access the instance. This is done by getting an authorization token from the instance. The token is used to authenticate the GH Actions requests to the instance. - -The reserved instance needs to be **released** after the tests are complete. This is an important step to ensure that the instance is available for future tests. PlatformOS' internal solution involves a pool of 6 instances (ci.1, ci.2, ci.3, ci.4, ci.5, ci.6) shared across projects. - -The process works as follows: - -- The first available instance that is not currently used by any other GitHub Action is taken and removed from the pool. -- This prevents multiple projects from running their tests in parallel on the same instance, which would cause conflicts. -- The instance is reserved for the duration of the tests, regardless of whether the tests fail or succeed. -- GH Actions are authorized to access the instance by getting an authorization token from the instance. -- Once the tests are done, the instance is given back to the pool. -- Without this reserve and release mechanism, we would quickly run out of available instances, preventing new tests from running. - -### Custom Action Details - -The custom action `Platform-OS/ci-repository-reserve-instance-url@0.1.2` handles reserving and releasing instances, and getting authorization tokens from them. It operates based on the method provided (`reserve`, `get-token` or `release`). The action communicates with the CI repository to manage instance reservations. - -## Replace old worfklow code like - -Replace your existing code for releasing an instance: - -### beginning - -```yaml - - name: Get ci-instance-url - shell: sh - run: | - export MPKIT_URL=https://$(./scripts/ci/repository reserve) - export REPORT_PATH=$(echo $MPKIT_URL | cut -d'/' -f3)/$(date +'%Y-%m-%d-%H-%M-%S') - echo "MPKIT_URL=$MPKIT_URL" >> $GITHUB_ENV - echo "REPORT_PATH=$REPORT_PATH" >> $GITHUB_ENV -``` - -### closing - -```yaml - - name: Release instance - if: ${{ always() }} - shell: sh - run: | - ./scripts/ci/repository release -``` - -## With the following - -Use the following code to reserve an instance: - -### beginning - -```yaml - reserve-ci-instance: - runs-on: ubuntu-latest - container: alpine:3.15 - outputs: - mpkit-url: ${{ steps.reserve.outputs.mpkit-url }} - report-path: ${{ steps.reserve.outputs.report-path }} - steps: - - name: reserve ci-instance-url - id: reserve - uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 - with: - repository-url: https://ci-repository.staging.oregon.platform-os.com - method: reserve - pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }} -``` - -### authorization - -```yaml - steps: - - name: Get MPKIT token - id: get-token - uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 - with: - method: get-token - repository-url: ${{ vars.CI_PS_REPOSITORY_URL }} - pos-ci-repo-token: ${{ secrets.POS_CI_PS_REPO_ACCESS_TOKEN }} - - - name: Deploy - shell: sh - env: - MPKIT_TOKEN: ${{ steps.get-token.outputs.mpkit-token }} -``` - -### closing - -```yaml - cleanup: - if: ${{ always() }} - needs: ["reserve-ci-instance","deploy","tests"] - runs-on: ubuntu-latest - container: alpine:3.15 - steps: - - name: release ci-instance-url back to the instance-pool - uses: Platform-OS/ci-repository-reserve-instance-url@0.1.2 - with: - method: release - repository-url: https://ci-repository.staging.oregon.platform-os.com - pos-ci-repo-token: ${{ secrets.POS_CI_REPO_ACCESS_TOKEN }} -``` - -## Update Your Jobs - -Also update your jobs code with the following: - -```yaml -deploy: - needs: ["reserve-ci-instance"] - env: - MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }} - [...] - -tests: - needs: ["reserve-ci-instance", "deploy"] - env: - MPKIT_URL: ${{ needs.reserve-ci-instance.outputs.mpkit-url }} - REPORT_PATH: ${{ needs.reserve-ci-instance.outputs.report-path }} - [...] -``` - -## Troubleshooting - -### Using `act` for Testing - -You can use the `act` tool for local testing of GitHub Actions: - -- [act](https://github.com/nektos/act) - -Usage: - -```sh -act pull_request --secret-file .secrets --pull=false - -act pull_request --secret-file .secrets -``` - -## Script Details - -The action's entry point script (`entrypoint.sh`) handles the logic for reserving, extracting and masking tokens and releasing instances. The script processes the method argument to perform the appropriate action (reserve or release). - -- **Script Entry Point**: `entrypoint.sh` is designed for use in Docker. -- **Method Argument**: The first argument provided to the script determines the method. - -### Key Actions: -1. **Release**: Triggers a delete request when the method is `release`. - -2. **Get Token**: Sends a post request and logs the token in a masked form when the method is `get-token`. - -3. **Reserve**: Sends a post request and logs it when the method is `reserve`. - -Additional Responsibilities: - -- **Instance Setup and Report Path Preparation**: The script sets up the instance and prepares the report path. -- **Persistent Log Access**: It ensures that you can access previous test logs even after running new tests. This is important for accessing test results at a later time (e.g., triggering a test on Friday and accessing the results on Monday). -- **Instance URL**: The script logs the instance URL for reference. -- **Authorization Token**: It logs the authorization token in a masked form. -- **Timestamped Report Path**: To keep logs organized and unique, it creates a report path with the current timestamp. - -For more details, check the [entrypoint.sh script](https://github.com/Platform-OS/ci-repository-reserve-instance-url/blob/main/entrypoint.sh). - -### Instance Naming Conventions - -The custom action still uses some legacy naming conventions like `mpkit-url`. This refers to the instance URL. For clarity, consider this as the instance URL. diff --git a/ci-repository-reserve-instance-url/action.yaml b/ci-repository-reserve-instance-url/action.yaml deleted file mode 100644 index 63d9402..0000000 --- a/ci-repository-reserve-instance-url/action.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# action.yml -name: 'Get POS CI Instance URL' -description: 'populate env with ci-instance-url and report-url variables' -inputs: - method: # id of input - description: 'method to execute. either reserve or release' - required: true - default: 'reserve' - repository-url: # id of input - description: 'url of the instance repository' - required: true - pos-ci-repo-token: # id of input - description: 'pos cli ci repo access token' - required: true -outputs: - mpkit-token: - description: 'mpkit token' - mpkit-url: # id of output - description: 'reserved instance url' - report-path: - description: 'report-path' -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.method }} - - ${{ inputs.repository-url }} - - ${{ inputs.pos-ci-repo-token }} diff --git a/ci-repository-reserve-instance-url/entrypoint.sh b/ci-repository-reserve-instance-url/entrypoint.sh deleted file mode 100755 index 5a9fbd8..0000000 --- a/ci-repository-reserve-instance-url/entrypoint.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -l - -set -eu - -METHOD=$1 -CI_REPO_URL=${2}/api/instances -POS_CI_REPO_ACCESS_TOKEN=$3 - -GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-octocat/Hello-World} -GITHUB_RUN_ID=${GITHUB_RUN_ID:-run-888} - -CLIENT=${GITHUB_REPOSITORY}--${GITHUB_RUN_ID}--${GITHUB_RUN_NUMBER:-0} -CLIENT=${CLIENT/\//--} - -request() { - curl -s -X$1 \ - -H "Authorization: Bearer $POS_CI_REPO_ACCESS_TOKEN" \ - -H 'Content-type: application/json' \ - -d "{\"client\":\"$CLIENT\"}" \ - --fail-with-body \ - ${CI_REPO_URL}/${2:-} -} - -case $METHOD in - - release) - echo releasing instance - request DELETE release - ;; - - get-token) - set +e - request POST get-token > .log - RESCODE=$? - set -e - if [ $RESCODE != 0 ]; then - echo "get-token request failed. [${RESCODE}]" - cat .log - exit 2137 - else - MPKIT_TOKEN=$(cat .log) - fi - - echo "::add-mask::$MPKIT_TOKEN" - echo "mpkit-token=$MPKIT_TOKEN" >> $GITHUB_OUTPUT - ;; - - reserve) - set +e - request POST reserve > .log - RESCODE=$? - set -e - if [ $RESCODE != 0 ]; then - echo "Reserve request failed. [${RESCODE}]" - cat .log - exit 2137 - else - INSTANCE_DOMAIN=$(cat .log) - fi - - echo "mpkit-url=https://$INSTANCE_DOMAIN" >> $GITHUB_OUTPUT - echo "report-path=${INSTANCE_DOMAIN}/$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT - ;; - - test) - request POST test - ;; - - all) - request POST - ;; - *) - echo $METHOD command not found: Usage: ./scripts/ci/repository all | reserve | release -esac diff --git a/pos-module-chat/package.json b/pos-module-chat/package.json index e21e80e..768f295 100644 --- a/pos-module-chat/package.json +++ b/pos-module-chat/package.json @@ -1,6 +1,6 @@ { "scripts": { - "pw-tests": "npx playwright test tests --project=test --reporter=list", + "pw-tests": "playwright test tests --project=test --reporter=list", "test": "playwright test", "install: playwright": "npx playwright install" },