diff --git a/.github/workflows/check-outdated.yml b/.github/workflows/ci-check-outdated-deps.yml similarity index 70% rename from .github/workflows/check-outdated.yml rename to .github/workflows/ci-check-outdated-deps.yml index 1a0ca5b0a..478a7e9c7 100644 --- a/.github/workflows/check-outdated.yml +++ b/.github/workflows/ci-check-outdated-deps.yml @@ -1,24 +1,25 @@ -name: Check for Outdated NPM Dependencies +name: CI - Check for Outdated NPM Dependencies on: [push] jobs: check-outdated: runs-on: ubuntu-latest + if: github.ref != 'refs/heads/master' steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: '20.11.0' - name: Install dependencies run: npm install - - name: Install npm 10.3.0 - run: npm install -g npm@10.3.0 + - name: Install npm 10.9.3 + run: npm install -g npm@10.9.3 # Optional: Clear npm cache to prevent cache-related issues - name: Clear npm cache diff --git a/.github/workflows/ci-cypress.yml b/.github/workflows/ci-cypress.yml new file mode 100644 index 000000000..1f5122fc2 --- /dev/null +++ b/.github/workflows/ci-cypress.yml @@ -0,0 +1,78 @@ +# .github/workflows/ci-cypress.yml +name: CI - Cypress tests + +on: + push: + +jobs: + cypress-tests: + runs-on: ubuntu-latest + container: + image: cypress/included:12.17.4 + strategy: + matrix: + node-version: + - '20' + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install NPM dependencies + run: npm install + + - name: Write holder data fixture + run: | + echo "$CYPRESS_HOLDER_CHANGE_PERSONALDATA_JSON" > cypress/fixtures/holderChangePersonaldata.json + shell: bash + env: + CYPRESS_HOLDER_CHANGE_PERSONALDATA_JSON: ${{ secrets.CYPRESS_HOLDER_CHANGE_PERSONALDATA_JSON }} + + - name: Run Cypress tests + uses: cypress-io/github-action@v6 + with: + start: npm run start-ci + wait-on: 'http://localhost:3000' + wait-on-timeout: 60 + browser: chrome + headed: false + working-directory: ./ + config: + baseUrl=http://localhost:3000 + + env: + PUBLIC_URL: ${{ secrets.PUBLIC_URL }} + VITE_WEBFORMS_API_URL: ${{ secrets.VITE_WEBFORMS_API_URL }} + VITE_PLAUSIBLE_TRACK_DOMAIN: ${{ secrets.VITE_PLAUSIBLE_TRACK_DOMAIN }} + VITE_PLAUSIBLE_APIHOST_URL: ${{ secrets.VITE_PLAUSIBLE_APIHOST_URL }} + VITE_CONTRACT_JSON_DATA: ${{ secrets.VITE_CONTRACT_JSON_DATA }} + VITE_GENERATION_INVESTMENTS_JSON_DATA: ${{ secrets.VITE_GENERATION_INVESTMENTS_JSON_DATA }} + VITE_GENERATION_ASSIGNMENTS_JSON_DATA: ${{ secrets.VITE_GENERATION_ASSIGNMENTS_JSON_DATA }} + VITE_GENERATION_OUTSIDE_ASSIGNMENTS: ${{ secrets.VITE_GENERATION_OUTSIDE_ASSIGNMENTS }} + VITE_FEATURE_FLAGS: ${{ secrets.VITE_FEATURE_FLAGS }} + VITE_SHOW_D1_POWER_MODIFICATION_CHOOSER: ${{ secrets.VITE_SHOW_D1_POWER_MODIFICATION_CHOOSER }} + VITE_GOOGLE_MAPS_JAVASCRIPT_API_KEY: ${{ secrets.VITE_GOOGLE_MAPS_JAVASCRIPT_API_KEY }} + VITE_GENERATE_SOURCEMAP: ${{ secrets.VITE_GENERATE_SOURCEMAP }} + VITE_MATOMO_URL: ${{ secrets.VITE_MATOMO_URL }} + VITE_MATOMO_SITE_ID: ${{ secrets.VITE_MATOMO_SITE_ID }} + REACT_APP_DISABLE_ANIMATIONS: true + CYPRESS_pageLoadTimeout: 6000 + ELECTRON_DISABLE_GPU: 1 + CHROME_DISABLE_GPU: true + + - name: Clean up fixture + if: always() + run: rm -f cypress/fixtures/holderChangePersonaldata.json + + - name: Notify + uses: Som-Energia/ghactions-notify@main + if: always() + with: + webhook: ${{ secrets.WEBHOOK_ALERTES_WEBAPPS }} \ No newline at end of file diff --git a/.github/workflows/ci-vitest.yml b/.github/workflows/ci-vitest.yml new file mode 100644 index 000000000..5c25d08d8 --- /dev/null +++ b/.github/workflows/ci-vitest.yml @@ -0,0 +1,35 @@ +# .github/workflows/ci-vitest.yml +name: CI - Vitest tests + +on: + push: + +jobs: + vitest-tests: + runs-on: ubuntu-latest + if: github.ref != 'refs/heads/master' + strategy: + matrix: + node-version: + - '20' + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install dependencies + run: npm install && npm install coveralls --save-dev + + - name: Run Vitest tests + run: npm run test-ci + + - name: Notify + uses: Som-Energia/ghactions-notify@main + if: always() + with: + webhook: ${{ secrets.WEBHOOK_ALERTES_WEBAPPS }} diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml deleted file mode 100644 index e8b5dc9e6..000000000 --- a/.github/workflows/cypress.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: cypress webforms-ui -on: [push] -env: - REACT_APP_API_BASE_URL: ${{ secrets.API_BASE_URL }} -jobs: - cypress-run: - runs-on: ubuntu-20.04 - name: cypress webforms-ui on chrome - environment: cypress - steps: - - uses: actions/checkout@v1 - - name: Generate package-lock - run: npm install - - uses: cypress-io/github-action@v6 - with: - install-command: npm install - browser: chrome - record: true - parallel: true - start: npm run start - wait-on: 'http://localhost:3000' - config: baseUrl=http://localhost:3000 - env: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - # Pass GitHub token to allow accurately detecting a build vs a re-run build - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - uses: actions/upload-artifact@v4 - if: always() - with: - name: cypress-screenshots - path: cypress/screenshots diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f3d5b6047..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,50 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the main branch - push: - pull_request: - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# 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: - # The type of runner that the job will run on - runs-on: ubuntu-latest - strategy: - matrix: - node-version: - - '20' - - name: Node ${{ matrix.node-version }} - # 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@v2 - - - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - - name: Install dependencies - run: | - #make ui-deploy - npm install - npm install coveralls --save-dev - - - name: Unit tests - run: | - #make testsa - npm run test - - - name: Notify - uses: Som-Energia/ghactions-notify@main - if: always() - with: - webhook: ${{ secrets.WEBHOOK_ALERTES_WEBAPPS }} - diff --git a/package.json b/package.json index 02abc53d1..51071b454 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,17 @@ "private": false, "scripts": { "start": "export VITE_APP_VERSION=$(git describe --tags) && vite", + "start-ci": "export VITE_APP_VERSION=$(git describe --tags) && vite --host", "build": "export VITE_APP_VERSION=$(git describe --tags) && vite build", "build:ov": "npm run build -- --mode=ov && ./scripts/rename-assets-ov.sh", "build:wp": "npm run build -- --mode=wp", "build:pre": "npm run build -- --mode=pre", "build:vercel": "npm run build -- --mode=vercel", "test": "TZ=Europe/Madrid vitest", + "test-ci": "TZ=Europe/Madrid vitest run", "test:coverage": "TZ=Europe/Madrid vitest run --coverage", "cypress": "TZ=Europe/Madrid cypress open", + "cypress-ci": "TZ=Europe/Madrid cypress run --browser chrome --headless", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", "i18n-extract": "./node_modules/.bin/i18next src/**/*.js* -o src/i18n/locale-xx.json -s", "i18n-lint": "./scripts/lint-i18n.sh",