From 87ba779c30f445a2811ead1f966d06a5483f80ab Mon Sep 17 00:00:00 2001 From: Jozef Kralik Date: Fri, 8 Dec 2023 15:46:30 +0000 Subject: [PATCH 1/4] integrate playwright to github workflow --- .github/workflows/playwright.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 00000000..529ce5e3 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,32 @@ +name: Playwright Tests +on: + push: + branches: [ main, master ] + pull_request: + branches: [ main, master ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 + - name: Install dependencies + working-directory: ./web/playwright + run: npm ci + - name: Install Playwright Browsers + working-directory: ./web/playwright + run: npx playwright install --with-deps + - name: Install dotenv + run: npm install --save dotenv + - name: Run Playwright tests + working-directory: ./web/playwright + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: ./web/playwright/playwright-report/ + retention-days: 30 From 53ed9f6ecf497d25206138f636d5939658964dbd Mon Sep 17 00:00:00 2001 From: Jozef Kralik Date: Fri, 8 Dec 2023 15:52:08 +0000 Subject: [PATCH 2/4] revert me!!! --- .github/workflows/build-publish.yaml | 64 ------------------- .github/workflows/buildTestBinaries.yml | 54 ----------------- .github/workflows/checkFormat.yml | 24 -------- .github/workflows/ghcr-cleanup.yaml | 81 ------------------------- .github/workflows/golangci-lint.yml | 26 -------- .github/workflows/release.yml | 50 --------------- .github/workflows/staticAnalysis.yml | 39 ------------ .github/workflows/test.yml | 41 ------------- 8 files changed, 379 deletions(-) delete mode 100644 .github/workflows/build-publish.yaml delete mode 100644 .github/workflows/buildTestBinaries.yml delete mode 100644 .github/workflows/checkFormat.yml delete mode 100644 .github/workflows/ghcr-cleanup.yaml delete mode 100644 .github/workflows/golangci-lint.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/staticAnalysis.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build-publish.yaml b/.github/workflows/build-publish.yaml deleted file mode 100644 index d2b74806..00000000 --- a/.github/workflows/build-publish.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: Build and publish image -on: - push: - tags: - - "*" - pull_request: - branches: - - main - -env: - REGISTRY: ghcr.io - - -jobs: - build-and-publish-image: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: recursive - - name: build-web - run: | - mkdir -p `pwd`/.tmp - make build-web UI_FILE=`pwd`/.tmp/ui.tar.gz - - uses: docker/setup-qemu-action@v3 - - uses: docker/setup-buildx-action@v3 - id: buildx - - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Extract metadata (tags, labels) for docker image - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.REGISTRY }}/${{ github.repository }} - tags: | - type=raw,enable={{is_default_branch}},value=vnext - type=sha,enable={{is_default_branch}},prefix=vnext-,format=short - type=ref,event=pr,prefix=vnext-pr,suffix=-{{sha}} - type=ref,event=pr,prefix=vnext-pr - type=ref,enable={{is_default_branch}},event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - - name: Build and publish image - uses: docker/build-push-action@v5 - with: - context: . - file: ./docker/Dockerfile - platforms: linux/amd64,linux/arm64 - builder: ${{ steps.buildx.outputs.name }} - build-args: | - UI_FILE=.tmp/ui.tar.gz - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - - name: Clean up - if: ${{ always() }} - run: | - shopt -s dotglob - sudo rm -r * diff --git a/.github/workflows/buildTestBinaries.yml b/.github/workflows/buildTestBinaries.yml deleted file mode 100644 index ce46a65b..00000000 --- a/.github/workflows/buildTestBinaries.yml +++ /dev/null @@ -1,54 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Build test binaries - -# Controls when the action will run. Triggers the workflow push is only on main branch and PR on any branch. -on: - push: - branches: - - main - pull_request: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build-binaries: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: true - - uses: actions/setup-go@v4 - with: - go-version: "^1.18" # The Go version to download (if necessary) and use. - - - name: Set version and ui_file - id: vars - run: | - git tag $(git describe --tags --abbrev=0)-$(git rev-parse --short HEAD) - echo "version=$(git describe --tags --abbrev=0)" >> $GITHUB_OUTPUT - echo "ui_file=$(pwd)/.tmp/ui.tar.gz" >> $GITHUB_OUTPUT - - - name: Build client - uses: goreleaser/goreleaser-action@v4 - with: - # version of goreleaser which will be used - version: latest - args: release --rm-dist --skip-publish --skip-announce - env: - UI_SEPARATOR: "--------UI--------" - UI_FILE: ${{ steps.vars.outputs.ui_file }} - - - name: Upload assets - uses: actions/upload-artifact@v3 - with: - name: client_application-${{ steps.vars.outputs.version }} - path: | - .tmp/dist/*.tar.gz - .tmp/dist/*.zip - retention-days: 7 diff --git a/.github/workflows/checkFormat.yml b/.github/workflows/checkFormat.yml deleted file mode 100644 index 3eaf66fd..00000000 --- a/.github/workflows/checkFormat.yml +++ /dev/null @@ -1,24 +0,0 @@ -# Check that only correctly formatted golang code is merged -name: Check Format - -on: - pull_request: - branches: - - main - -jobs: - format: - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v4 - with: - # fetch branches and history so `git merge-base` in check-format-on-diff works correctly - fetch-depth: 0 - - uses: actions/setup-go@v4 - with: - go-version: "^1.18" # The Go version to download (if necessary) and use. - - - name: Check formatting - shell: bash - run: tools/format/check-format-on-diff.sh --simplify --branch origin/${{ github.base_ref }} diff --git a/.github/workflows/ghcr-cleanup.yaml b/.github/workflows/ghcr-cleanup.yaml deleted file mode 100644 index c1575157..00000000 --- a/.github/workflows/ghcr-cleanup.yaml +++ /dev/null @@ -1,81 +0,0 @@ -name: Delete old ghcr images -on: - schedule: - - cron: "15 1 * * *" # every day at 1:15am - pull_request: - types: [closed] - workflow_dispatch: - -jobs: - pull-request-ghcr-cleanup: - if: ${{ github.event_name == 'pull_request' }} - name: Delete images related to closed PR - runs-on: ubuntu-latest - steps: - - name: Delete images related to closed PR (1) - id: run-1 - continue-on-error: true - uses: snok/container-retention-policy@v2 - with: - image-names: client-application - cut-off: now UTC - account-type: org - org-name: plgd-dev - filter-tags: vnext-pr${{ github.event.pull_request.number }}* - token: ${{ secrets.GHCR_CLEANUP_PAT }} - token-type: pat - - if: ${{ steps.run-1.outcome == 'failure' }} - run: sleep 60 - - name: Delete images related to closed PR (2) - id: run-2 - if: ${{ steps.run-1.outcome == 'failure' }} - continue-on-error: true - uses: snok/container-retention-policy@v2 - with: - image-names: client-application - cut-off: now UTC - account-type: org - org-name: plgd-dev - filter-tags: vnext-pr${{ github.event.pull_request.number }}* - token: ${{ secrets.GHCR_CLEANUP_PAT }} - token-type: pat - - if: ${{ steps.run-2.outcome == 'failure' }} - run: sleep 60 - - name: Delete images related to closed PR (3) - if: ${{ steps.run-2.outcome == 'failure' }} - uses: snok/container-retention-policy@v2 - with: - image-names: client-application - cut-off: now UTC - account-type: org - org-name: plgd-dev - filter-tags: vnext-pr${{ github.event.pull_request.number }}* - token: ${{ secrets.GHCR_CLEANUP_PAT }} - token-type: pat - nightly-ghcr-cleanup: - if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - name: Delete stale or untagged images - runs-on: ubuntu-latest - steps: - - name: Checkout local actions - uses: actions/checkout@v4 - - name: Delete stale or untagged images (1) - id: run-1 - continue-on-error: true - uses: ./.github/actions/cleanup-stale - with: - token: ${{ secrets.GHCR_CLEANUP_PAT }} - - name: Delete stale or untagged images (2) - id: run-2 - if: ${{ steps.run-1.outcome == 'failure' }} - with: - token: ${{ secrets.GHCR_CLEANUP_PAT }} - delay: 60 - continue-on-error: true - uses: ./.github/actions/cleanup-stale - - name: Delete stale or untagged images (3) - if: ${{ steps.run-2.outcome == 'failure' }} - uses: ./.github/actions/cleanup-stale - with: - token: ${{ secrets.GHCR_CLEANUP_PAT }} - delay: 60 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index e5247677..00000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Golangci-lint - -# golangci-lint is a fast Go linters runner. It runs linters in parallel, -# uses caching, supports yaml config, has integrations with all major IDE and -# has dozens of linters included. -# see: https://github.com/golangci/golangci-lint-action - -on: - pull_request: - branches: - - main -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: "^1.18" # The Go version to download (if necessary) and use. - - run: go version - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --timeout=5m diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 707f88c3..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: goreleaser - -on: - push: - # run only against tags - tags: - - '*' - -permissions: - contents: write - # packages: write - # issues: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - submodules: true - - - name: Fetch all tags - run: git fetch --force --tags - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: 1.18 - - - name: Set ui_file - id: vars - run: | - echo "ui_file=$(pwd)/.tmp/ui.tar.gz" >> $GITHUB_OUTPUT - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v4 - with: - # either 'goreleaser' (default) or 'goreleaser-pro' - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - UI_SEPARATOR: "--------UI--------" - UI_FILE: ${{ steps.vars.outputs.ui_file }} - # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution - # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} \ No newline at end of file diff --git a/.github/workflows/staticAnalysis.yml b/.github/workflows/staticAnalysis.yml deleted file mode 100644 index 1ea6074b..00000000 --- a/.github/workflows/staticAnalysis.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Run static analysis checks -name: Static Analysis - -on: - pull_request: - branches: - - main - -jobs: - analysis: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version: "^1.18" # The Go version to download (if necessary) and use. - - run: go version - - - name: Run go vet - run: go vet ./... - - - name: Install and run errcheck - run: | - export PATH=${PATH}:`go env GOPATH`/bin - go install github.com/kisielk/errcheck@latest - errcheck ./... - - # aligncheck doesn't yet support go1.18 - # - name: Install and run aligncheck - # run: | - # go get -u gitlab.com/opennota/check/cmd/aligncheck@latest - # aligncheck ./... || echo "aligncheck detected inefficiently packed structs" - - - name: Check yaml field names and yaml tags - run: tools/validate/validateYaml.py - - - name: Check json tags - run: tools/validate/validateJson.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index a6ca23c5..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: Test - -# Controls when the action will run. Triggers the workflow push is only on main branch and PR on any branch. -on: - push: - branches: - - main - tags: - - "*" - pull_request: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - test: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v4 - - - uses: actions/setup-go@v4 - with: - go-version: "^1.18" # The Go version to download (if necessary) and use. - - - name: Run a test - run: make test - - - name: Publish the coverage for main branch - if: ${{ github.ref == 'refs/heads/main' }} - run: bash <(curl -s https://codecov.io/bash) - - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From f9eba3946db2071e742ffec3f9c5d2b23c839b2f Mon Sep 17 00:00:00 2001 From: Jozef Kralik Date: Fri, 8 Dec 2023 16:00:44 +0000 Subject: [PATCH 3/4] get submodules --- .github/workflows/playwright.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 529ce5e3..ab959a46 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + with: + submodules: true - uses: actions/setup-node@v4 with: node-version: 16 From d8f14f36cca87682dcce24cd981447caf209f6a4 Mon Sep 17 00:00:00 2001 From: Jozef Kralik Date: Fri, 8 Dec 2023 16:08:56 +0000 Subject: [PATCH 4/4] build client application --- .github/workflows/playwright.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index ab959a46..6428987a 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -23,9 +23,13 @@ jobs: run: npx playwright install --with-deps - name: Install dotenv run: npm install --save dotenv + - name: Build client application + run: make build + - name: Run client application + run: .tmp/dist/client-application_linux_amd64_v1/client-application & - name: Run Playwright tests working-directory: ./web/playwright - run: npx playwright test + run: REACT_APP_HTTP_GATEWAY_ADDRESS=localhost:8080 npx playwright test - uses: actions/upload-artifact@v3 if: always() with: