From 52acd7986225f909b07dfb353749bb352920f893 Mon Sep 17 00:00:00 2001 From: BacLuc Date: Mon, 31 Jul 2023 22:04:24 +0200 Subject: [PATCH] CI: run e2e tests 50 times --- .github/workflows/continuous-integration.yml | 296 ++----------------- 1 file changed, 25 insertions(+), 271 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index eeddc015c07..0dd4ce0c139 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -20,245 +20,6 @@ env: COMPOSE_DOCKER_CLI_BUILD: 1 jobs: - api-cs-check: - name: 'Lint: API (php-cs-fixer)' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2.8' - tools: composer:2.5.0 - coverage: xdebug - - - name: Get Composer Cache Directory - id: composer-cache - run: 'echo "dir=$(composer config cache-files-dir)" | tr -d "\n" >> $GITHUB_OUTPUT' - working-directory: api - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - run: composer install --no-interaction --no-plugins --no-scripts --prefer-dist - working-directory: api - - - run: php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --diff - working-directory: api - - frontend-eslint: - name: 'Lint: Frontend (ESLint)' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: actions/setup-node@v3 - with: - node-version: '20.5.0' - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - run: npm ci --no-audit - working-directory: frontend - - - run: | - npm run lint:check:eslint - result=$(npm run lint:check:prettier) - echo $result - if echo $result | grep -E "Code style issues found"; then - exit 1 - fi - working-directory: frontend - - print-eslint: - name: 'Lint: Print (ESLint)' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: actions/setup-node@v3 - with: - node-version: '20.5.0' - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - run: npm ci --no-audit - working-directory: print - - - run: | - npm run lint:check:eslint - result=$(npm run lint:check:prettier) - echo $result - if echo $result | grep -E "Code style issues found"; then - exit 1 - fi - working-directory: print - - api-tests: - name: 'Tests: API' - runs-on: ubuntu-latest - env: - TEST_DATABASE_URL: postgresql://ecamp3:ecamp3@localhost:5432/ecamp3test?serverVersion=15&charset=utf8 - - services: - postgres: - image: 'postgres:15-alpine' - env: - POSTGRES_DB: 'ecamp3test' - POSTGRES_PASSWORD: 'ecamp3' - POSTGRES_USER: 'ecamp3' - ports: - - '5432:5432' - options: >- - --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2.8' - extensions: intl-73.1 - tools: composer:2.5.0 - coverage: xdebug - - - name: Get Composer Cache Directory - id: composer-cache - run: 'echo "dir=$(composer config cache-files-dir)" | tr -d "\n" >> $GITHUB_OUTPUT' - working-directory: api - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - - run: composer install --prefer-dist --no-progress --no-interaction - working-directory: api - - - run: | - mkdir -p var/cache var/log - jwt_passphrase=${JWT_PASSPHRASE:-$(grep ''^JWT_PASSPHRASE='' .env | cut -f 2 -d ''='')} - echo "Generating public / private keys for JWT" - mkdir -p config/jwt - echo "$jwt_passphrase" | openssl genpkey -out config/jwt/private.pem -pass stdin -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 - echo "$jwt_passphrase" | openssl pkey -in config/jwt/private.pem -passin stdin -out config/jwt/public.pem -pubout - setfacl -R -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt - setfacl -dR -m u:www-data:rX -m u:"$(whoami)":rwX config/jwt - working-directory: api - - - run: php bin/console doctrine:migrations:migrate --no-interaction -e test - working-directory: api - - - run: composer test - working-directory: api - - - name: send coveralls report - run: | - sed -i "s|$(pwd)/api/|api/|g" api/build/logs/clover.xml - api/vendor/bin/php-coveralls -v \ - --coverage_clover api/build/logs/clover.xml \ - --json_path api/build/logs/coveralls-upload.json - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: api - - frontend-tests: - name: 'Tests: Frontend' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: actions/setup-node@v3 - with: - node-version: '20.5.0' - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - run: npm ci --no-audit - working-directory: frontend - - - run: npm run build - working-directory: frontend - - - run: npm run test:unit - working-directory: frontend - - - name: send coverage info - run: | - sed -i "s|src/|frontend/src/|g" frontend/data/coverage/lcov.info - cat frontend/data/coverage/lcov.info | npx coveralls . - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_SERVICE_NAME: github - COVERALLS_SERVICE_NUMBER: ${{ github.run_id }} - CI_PULL_REQUEST: ${{ github.event.number }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: frontend - - print-tests: - name: 'Tests: Print' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 - - - uses: actions/setup-node@v3 - with: - node-version: '20.5.0' - - - uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 # v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - run: npm ci --no-audit - working-directory: print - - - run: npm run build - working-directory: print - env: - NODE_OPTIONS: --openssl-legacy-provider - - - run: npm run test - working-directory: print - - - name: send coverage info - run: | - sed -i "s|SF:|SF:print/|g" print/coverage/lcov.info - cat print/coverage/lcov.info | npx coveralls . - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_SERVICE_NAME: github - COVERALLS_SERVICE_NUMBER: ${{ github.run_id }} - CI_PULL_REQUEST: ${{ github.event.number }} - COVERALLS_PARALLEL: true - COVERALLS_FLAG_NAME: print e2e-tests-build: name: 'Tests: End-to-end (build job)' @@ -305,11 +66,34 @@ jobs: with: name: e2e-tests-images path: /tmp/ecamp3-dev-*.tar + + large-array: + name: 'create-large-matrix' + runs-on: ubuntu-latest + outputs: + array: ${{ steps.array.outputs.result }} + + steps: + - name: Get lowercase repo owner name + uses: actions/github-script@v6 + id: array + with: + script: | + function range(start, stop) { + return Array(stop - start) + .fill(start) + .map((value, index) => value + index); + } + return range(0, 50) + + e2e-tests-run: name: 'Tests: End-to-end' runs-on: ubuntu-latest - needs: e2e-tests-build + needs: + - e2e-tests-build + - large-array timeout-minutes: 20 strategy: fail-fast: false @@ -319,6 +103,7 @@ jobs: - chrome - firefox - edge + array: ${{ fromJSON(needs.large-array.outputs.array) }} steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 @@ -369,34 +154,3 @@ jobs: # print docker container logs (good for debugging; can be disabled again later on) - run: docker compose logs --tail="all" if: always() - - coveralls-finished: - name: 'Finish coveralls report' - needs: - - api-tests - - frontend-tests - - print-tests - runs-on: ubuntu-latest - steps: - - uses: coverallsapp/github-action@master - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - parallel-finished: true - - ci-passed-event: - name: 'Send out CI success event' - if: github.event_name == 'push' && (github.event.pull_request && github.event.pull_request.number) - needs: - - api-cs-check - - frontend-eslint - - print-eslint - - api-tests - - frontend-tests - - print-tests - - e2e-tests-run - runs-on: ubuntu-latest - steps: - - uses: peter-evans/repository-dispatch@26b39ed245ab8f31526069329e112ab2fb224588 # v2 - with: - event-type: ci-passed - client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'