From 9ac414303cc5c8adc59638d7e4dd86e1b14d3627 Mon Sep 17 00:00:00 2001 From: NuttyShrimp Date: Fri, 6 Sep 2024 11:21:54 +0200 Subject: [PATCH] feat(ci): add github action --- .github/workflows/cd.yml | 111 --------------------- .github/workflows/ci.yml | 166 ------------------------------- .github/workflows/playwright.yml | 42 ++++++++ loama/package.json | 4 +- loama/playwright.config.ts | 51 +++------- package.json | 4 +- 6 files changed, 60 insertions(+), 318 deletions(-) delete mode 100644 .github/workflows/cd.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/playwright.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 6747e85..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: Loama CD - -on: - push: - branches: [ "root" ] - -permissions: - contents: read - pages: write - id-token: write - -concurrency: - group: 'pages' - cancel-in-progress: true - -jobs: - controller-build: - name: 'Controller Build' - runs-on: ubuntu-latest - defaults: - run: - working-directory: controller - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Insall dependencies - run: pnpm install --frozen-lockfile - - name: Run Typescript Check - run: pnpm run build >> $GITHUB_STEP_SUMMARY - - name: Save distribution files - uses: actions/upload-artifact@v4 - with: - name: controller-dist - path: ${{github.workspace}}/controller/dist - - build: - name: 'Deploy App' - runs-on: ubuntu-latest - needs: controller-build - defaults: - run: - working-directory: loama - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Download controller dist - uses: actions/download-artifact@v4 - with: - name: controller-dist - path: ${{github.workspace}}/controller/dist - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies of controller - working-directory: controller - run: pnpm install --frozen-lockfile - - name: Install dependencies of loama - run: pnpm install --frozen-lockfile - - name: Build applicaion - run: pnpm run build - - name: 'Dup `index.html` to `404.html` for redirects' - run: cp dist/index.html dist/404.html - - name: Setup Pages - uses: actions/configure-pages@v4 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload dist folder - path: ${{github.workspace}}/loama/dist - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index ce339c8..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,166 +0,0 @@ -name: Loama CI - -on: - push: - branches: [ "root" ] - pull_request: - branches: [ "root" ] - -jobs: - eslint: - name: 'ESLint' - runs-on: ubuntu-latest - defaults: - run: - working-directory: loama - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Insall dependencies - run: pnpm install --frozen-lockfile - - name: Run Eslint - run: pnpm run lint:ci >> $GITHUB_STEP_SUMMARY - controller-tsc: - name: 'TSC (Controller)' - runs-on: ubuntu-latest - defaults: - run: - working-directory: controller - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Insall dependencies - run: pnpm install --frozen-lockfile - - name: Run Typescript Check - run: pnpm run build >> $GITHUB_STEP_SUMMARY - - name: Save distribution files - uses: actions/upload-artifact@v4 - with: - name: controller-dist - path: ${{github.workspace}}/controller/dist - - vue-tsc: - name: 'TSC (Loama)' - runs-on: ubuntu-latest - needs: controller-tsc - defaults: - run: - working-directory: loama - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Download controller dist - uses: actions/download-artifact@v4 - with: - name: controller-dist - path: ${{github.workspace}}/controller/dist - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Insall dependencies - run: pnpm install --frozen-lockfile - - name: Run Typescript Check - run: pnpm run type-check >> $GITHUB_STEP_SUMMARY - build: - name: 'Build (Loama)' - runs-on: ubuntu-latest - needs: controller-tsc - defaults: - run: - working-directory: loama - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Download controller dist - uses: actions/download-artifact@v4 - with: - name: controller-dist - path: ${{github.workspace}}/controller/dist - - name: Install Node.js - uses: actions/setup-node@v4 - - uses: pnpm/action-setup@v4 - name: Install PNPM - with: - version: latest - run_install: false - - name: Get pnpm store directory - shell: bash - id: cache - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup PNPM cache - env: - STORE_PATH: ${{ steps.cache.outputs.STORE_PATH }} - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install dependencies of controller - working-directory: controller - run: pnpm install --frozen-lockfile - - name: Install dependencies of loama - run: pnpm install --frozen-lockfile - - name: Run Typescript Check - run: pnpm run build-only >> $GITHUB_STEP_SUMMARY \ No newline at end of file diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml new file mode 100644 index 0000000..09aea99 --- /dev/null +++ b/.github/workflows/playwright.yml @@ -0,0 +1,42 @@ +name: Playwright Tests +on: + push: + branches: [ development ] + pull_request: + branches: [ development ] +jobs: + test: + timeout-minutes: 60 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: yarn + - name: Run install + uses: borales/actions-yarn@v5 + with: + cmd: install + - run: cd loama + - name: Build repo + uses: borales/actions-yarn@v5 + with: + cmd: build + - name: Install Playwright Browsers + uses: borales/actions-yarn@v5 + with: + cmd: playwright install --with-deps + dir: loama + - name: Run playwright tests + uses: borales/actions-yarn@v5 + with: + cmd: test + dir: loama + - uses: actions/upload-artifact@v4 + if: ${{ !cancelled() }} + with: + name: playwright-report + path: loama/playwright-report/ + retention-days: 30 diff --git a/loama/package.json b/loama/package.json index 260125f..dcb5a37 100644 --- a/loama/package.json +++ b/loama/package.json @@ -11,7 +11,9 @@ "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "format": "prettier --write src/", "lint:ci": "eslint . --config .eslintrc.cjs --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --format node_modules/eslint-formatter-markdown/markdown.js", - "test": "playwright test" + "test": "playwright test", + "pods:start": "community-solid-server -c @css:config/file.json --seedConfig ../css/config/seeds.json -f pods -p 8080", + "pods:reset": "rimraf pods" }, "engines": { "node": ">=20" diff --git a/loama/playwright.config.ts b/loama/playwright.config.ts index bee3a68..ee091e2 100644 --- a/loama/playwright.config.ts +++ b/loama/playwright.config.ts @@ -1,12 +1,5 @@ import { defineConfig, devices } from '@playwright/test'; -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -// import dotenv from 'dotenv'; -// dotenv.config({ path: path.resolve(__dirname, '.env') }); - /** * See https://playwright.dev/docs/test-configuration. */ @@ -24,10 +17,6 @@ export default defineConfig({ reporter: 'html', /* 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('/')`. */ - // baseURL: 'http://127.0.0.1:3000', - - /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry', baseURL: 'http://localhost:4173' }, @@ -48,32 +37,20 @@ export default defineConfig({ name: 'webkit', use: { ...devices['Desktop Safari'] }, }, - - /* Test against mobile viewports. */ - // { - // name: 'Mobile Chrome', - // use: { ...devices['Pixel 5'] }, - // }, - // { - // name: 'Mobile Safari', - // use: { ...devices['iPhone 12'] }, - // }, - - /* Test against branded browsers. */ - // { - // name: 'Microsoft Edge', - // use: { ...devices['Desktop Edge'], channel: 'msedge' }, - // }, - // { - // name: 'Google Chrome', - // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, - // }, ], - /* Run your local dev server before starting the tests */ - // webServer: { - // command: 'npm run start', - // url: 'http://127.0.0.1:3000', - // reuseExistingServer: !process.env.CI, - // }, + webServer: [ + { + command: 'yarn build && yarn preview', + url: 'http://localhost:4173', + timeout: 120 * 1000, + reuseExistingServer: !process.env.CI, + }, + { + command: 'yarn pods:reset && yarn pods:start', + url: 'http://localhost:8080', + timeout: 120 * 1000, + reuseExistingServer: !process.env.CI, + } + ] }); diff --git a/package.json b/package.json index 0fee2df..b691e50 100644 --- a/package.json +++ b/package.json @@ -10,9 +10,7 @@ ], "scripts": { "build": "nx run-many -t build", - "dev": "nx run-many --parallel=5 --exclude=doctorapp,mockbook -t dev", - "pods:start": "community-solid-server -c @css:config/file.json --seedConfig css/config/seeds.json -f pods -p 8080", - "pods:reset": "rimraf pods" + "dev": "nx run-many --parallel=5 --exclude=doctorapp,mockbook -t dev" }, "devDependencies": { "nx": "19.6.0"