diff --git a/.github/workflows/release.yml b/.github/workflows/binary.build.yml similarity index 75% rename from .github/workflows/release.yml rename to .github/workflows/binary.build.yml index c3f443b..3d0e80f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/binary.build.yml @@ -1,13 +1,11 @@ -name: Build and Release BackApp +name: Build BackApp on: - push: - tags: - - 'v*' workflow_dispatch: + workflow_call: permissions: - contents: write + contents: read jobs: frontend: @@ -24,7 +22,7 @@ jobs: cache: 'npm' cache-dependency-path: web/package-lock.json - - name: Build frontend (Node stage) + - name: Build frontend working-directory: web run: | if [ -f package-lock.json ]; then @@ -39,6 +37,7 @@ jobs: with: name: web-build path: server/static + retention-days: 30 build-linux-amd64: name: Build Linux x86_64 Binary @@ -59,7 +58,7 @@ jobs: with: go-version-file: server/go.mod - - name: Configure Go proxy (fallback) + - name: Configure Go proxy run: | go env -w GOPROXY=https://goproxy.io,direct go env -w GOSUMDB=sum.golang.org @@ -79,6 +78,7 @@ jobs: with: name: backapp-server-linux-amd64 path: server/backapp-server-linux-amd64 + retention-days: 30 build-linux-arm64: name: Build Linux ARM64 Binary @@ -94,7 +94,7 @@ jobs: name: web-build path: server/static - - name: Install cross compiler (arm64) + - name: Install cross compiler run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu - name: Set up Go @@ -102,7 +102,7 @@ jobs: with: go-version-file: server/go.mod - - name: Configure Go proxy (fallback) + - name: Configure Go proxy run: | go env -w GOPROXY=https://goproxy.io,direct go env -w GOSUMDB=sum.golang.org @@ -123,6 +123,7 @@ jobs: with: name: backapp-server-linux-arm64 path: server/backapp-server-linux-arm64 + retention-days: 30 build-raspberry-pi: name: Build Raspberry Pi 2 Binary @@ -140,18 +141,15 @@ jobs: name: web-build path: server/static - - name: Install cross compiler (armv7) + - name: Install cross compiler run: apt-get update && apt-get install -y gcc-arm-linux-gnueabihf ca-certificates - - name: Verify CA store - run: ls -l /etc/ssl/certs || true - - name: Set up Go uses: actions/setup-go@v5 with: go-version-file: server/go.mod - - name: Configure Go proxy (fallback) + - name: Configure Go proxy run: | go env -w GOPROXY=https://goproxy.io,direct go env -w GOSUMDB=sum.golang.org @@ -173,34 +171,4 @@ jobs: with: name: backapp-server-linux-armv7 path: server/backapp-server-linux-armv7 - - release: - name: Publish release - needs: [build-linux-amd64, build-linux-arm64, build-raspberry-pi] - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - steps: - - name: Download Linux amd64 artifact - uses: actions/download-artifact@v4 - with: - name: backapp-server-linux-amd64 - path: artifacts - - - name: Download Linux arm64 artifact - uses: actions/download-artifact@v4 - with: - name: backapp-server-linux-arm64 - path: artifacts - - - name: Download Linux armv7 artifact - uses: actions/download-artifact@v4 - with: - name: backapp-server-linux-armv7 - path: artifacts - - - name: Create GitHub release - uses: softprops/action-gh-release@v2 - with: - files: artifacts/* - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + retention-days: 30 diff --git a/.github/workflows/binary.release.yml b/.github/workflows/binary.release.yml new file mode 100644 index 0000000..ae6a4d7 --- /dev/null +++ b/.github/workflows/binary.release.yml @@ -0,0 +1,45 @@ +name: Release BackApp + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build-and-test: + uses: ./.github/workflows/binary.test.yml + secrets: inherit + release: + name: Publish release + needs: build-and-test + if: ${{ needs.build-and-test.result == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Download Linux amd64 artifact + uses: actions/download-artifact@v4 + with: + name: backapp-server-linux-amd64 + path: artifacts + + - name: Download Linux arm64 artifact + uses: actions/download-artifact@v4 + with: + name: backapp-server-linux-arm64 + path: artifacts + + - name: Download Linux armv7 artifact + uses: actions/download-artifact@v4 + with: + name: backapp-server-linux-armv7 + path: artifacts + + - name: Create GitHub release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.workflow_run.head_branch }} + files: artifacts/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/binary.test.yml b/.github/workflows/binary.test.yml new file mode 100644 index 0000000..e7bd9e9 --- /dev/null +++ b/.github/workflows/binary.test.yml @@ -0,0 +1,85 @@ +name: Test BackApp + +on: + workflow_dispatch: + workflow_call: + push: + branches: + - '**' + +permissions: + contents: read + checks: write + +jobs: + build: + uses: ./.github/workflows/binary.build.yml + secrets: inherit + test: + name: Run Playwright Tests + needs: build + if: ${{ needs.build.result == 'success' }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Download Linux amd64 binary + uses: actions/download-artifact@v4 + with: + name: backapp-server-linux-amd64 + path: build + + - name: Rename binary for testing + run: mv build/backapp-server-linux-amd64 build/backapp-server + + - name: Set executable permissions + run: chmod +x build/backapp-server + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + cache-dependency-path: web/package-lock.json + + - name: Install frontend dependencies + working-directory: web + run: npm ci + + - name: Cache Playwright Binaries + id: cache-playwright + uses: actions/cache@v4 + with: + path: | + ~/.cache/ms-playwright + key: playwright-${{ hashFiles('./web/package-lock.json') }} + - name: Install Playwright Browsers + if: steps.cache-playwright.outputs.cache-hit != 'true' + working-directory: ./web + run: npx playwright install --with-deps + + - name: Run Playwright tests with JUnit output + working-directory: web + run: | + npm run test-ci + + - name: Stop backend + if: always() + run: | + kill $(cat server/backapp.pid) || true + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v4 + if: success() || failure() # always run even if the previous step fails + with: + report_paths: web/test-results/results.xml + check_name: E2E Tests + detailed_summary: true + - name: Upload Test Report html + uses: actions/upload-artifact@v4 + if: failure() + with: + name: E2E html report + path: web/test-results/html + retention-days: 1 diff --git a/web/package.json b/web/package.json index 1b31b2e..15a786b 100644 --- a/web/package.json +++ b/web/package.json @@ -10,6 +10,7 @@ "pretest": "npm run build-server", "test": "playwright test", "test:ui": "playwright test --ui", + "test-ci": "playwright test", "test:report": "playwright show-report", "lint": "eslint .", "preview": "vite preview" diff --git a/web/playwright.config.ts b/web/playwright.config.ts index 191c7e5..89d5aa7 100644 --- a/web/playwright.config.ts +++ b/web/playwright.config.ts @@ -20,7 +20,11 @@ export default defineConfig({ retries: 0, workers: 1, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ - reporter: 'html', + reporter: [ + ['list'], + ['html', { outputFolder: 'test-results/html', open: 'never' }], + ['junit', { outputFile: 'test-results/results.xml' }] + ], /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('')`. */