fix: restore package-locks #1931
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
name: CI | |
jobs: | |
lint: | |
name: ESLint | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [14.x] | |
os: ["ubuntu-latest"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Restore ESLint from cache | |
uses: actions/cache@v2 | |
id: eslint_api_cache | |
with: | |
path: | | |
./node_modules | |
key: ${{ runner.os }}-${{ hashFiles('./package-lock.json') }} | |
- name: Install ESLint | |
if: steps.eslint_api_cache.outputs.cache-hit != 'true' | |
run: npm install eslint --ignore-scripts | |
- name: Run ESLint | |
uses: reviewdog/action-eslint@v1 | |
with: | |
fail_on_error: true | |
eslint_flags: 'packages/api' | |
web: | |
name: WEB tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [14.x] | |
os: ["ubuntu-latest"] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Restore dependencies from cache | |
uses: actions/cache@v2 | |
id: web_dependencies_cache | |
with: | |
path: | | |
**/web/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/web/package-lock.json') }} | |
- name: Install dependencies | |
if: steps.web_dependencies_cache.outputs.cache-hit != 'true' | |
working-directory: packages/web | |
run: npm ci | |
- name: Run WEB tests | |
working-directory: packages/web | |
run: npm run jest:ci | |
- name: Zip coverage data | |
working-directory: packages/web | |
run: zip -r coverage.zip ./coverage/ | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v2 | |
with: | |
name: web_coverage | |
path: | | |
**/web/coverage.zip | |
retention-days: 2 | |
api: | |
name: API tests | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [14.x] | |
os: ["ubuntu-latest"] | |
services: | |
plataforma-sabia-redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
plataforma-sabia-mysql: | |
image: mysql | |
env: | |
MYSQL_ROOT_PASSWORD: "" | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_DATABASE: sabia_testing | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Restore dependencies from cache | |
uses: actions/cache@v2 | |
id: api_dependencies_cache | |
with: | |
path: | | |
**/api/node_modules | |
key: ${{ runner.os }}-${{ hashFiles('**/api/package-lock.json') }} | |
- name: Install dependencies | |
if: steps.api_dependencies_cache.outputs.cache-hit != 'true' | |
working-directory: packages/api | |
run: npm ci | |
- name: Setup API environments | |
working-directory: packages/api | |
run: cp .env.testing .env | |
- name: Run API tests | |
working-directory: packages/api | |
run: npm run coverage | |
- name: Zip coverage data | |
working-directory: packages/api | |
run: zip -r coverage.zip ./.nyc_output | |
- name: Upload coverage data | |
uses: actions/upload-artifact@v2 | |
with: | |
name: api_coverage | |
path: | | |
**/api/coverage.zip | |
retention-days: 2 | |
# This job needs artifacts that are generated by each one of the above jobs | |
# Theoretically we should wait them to finish before start this one | |
# But, we can try to get coverage data after E2E tests run | |
# It should be enough time to web/api job get done | |
e2eAndCoverage: | |
name: E2E / Coverage | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
node-version: [14.x] | |
os: ["ubuntu-latest"] | |
services: | |
plataforma-sabia-redis: | |
image: redis | |
ports: | |
- 6379:6379 | |
options: >- | |
--health-cmd "redis-cli ping" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
plataforma-sabia-mysql: | |
image: mysql | |
env: | |
MYSQL_ROOT_PASSWORD: "" | |
MYSQL_ALLOW_EMPTY_PASSWORD: true | |
MYSQL_DATABASE: sabia_testing | |
ports: | |
- 3306:3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Restore dependencies from cache | |
uses: actions/cache@v2 | |
id: project_dependencies | |
with: | |
path: | | |
**/node_modules | |
~/.cache/Cypress | |
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }} | |
- name: Install project dependencies | |
if: steps.project_dependencies.outputs.cache-hit != 'true' | |
run: npm ci | |
- name: Prepare API for e2e tests | |
working-directory: packages/api | |
run: | | |
cp .env.testing .env | |
npm run migration:run -- --seed | |
- name: Run Cypress tests | |
uses: cypress-io/github-action@v2 | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
with: | |
command: npm run test:e2e:run | |
browser: chrome | |
install: false | |
- name: Download WEB coverage | |
uses: actions/download-artifact@v2 | |
with: | |
name: web_coverage | |
- name: Download API coverage | |
uses: actions/download-artifact@v2 | |
with: | |
name: api_coverage | |
- name: Unzip WEB coverage | |
working-directory: packages/web | |
run: | | |
unzip coverage.zip -d . | |
- name: Unzip API coverage | |
working-directory: packages/api | |
run: | | |
unzip coverage.zip -d . | |
- name: Merge coverages | |
run: | | |
npm run merge-coverage | |
- name: Coveralls | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.github_token }} |