Node.js CI #2498
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
name: Node.js CI | |
on: | |
push: | |
pull_request: | |
schedule: | |
- cron: '0 10 * * *' | |
jobs: | |
test: | |
name: 'Test on Node:${{ matrix.node-version }} OS:ubuntu-latest' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14, 16] | |
services: | |
postgres: | |
image: postgres | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
env: | |
TEST_PG_PORT: 5432 | |
TEST_PG_PASSWORD: postgres | |
TEST_MYSQL_PORT: 3306 | |
TEST_MYSQL_USER: root | |
TEST_MYSQL_PASSWORD: root | |
steps: | |
- uses: actions/checkout@v2 | |
- name: setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: 'node_modules' | |
key: ${{ runner.os }}-node-v${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }}-3 | |
- run: yarn --frozen-lockfile | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
- run: yarn lint | |
- run: yarn build | |
- run: yarn typecheck | |
- run: | | |
sudo systemctl start mysql.service | |
- run: yarn test | |
env: | |
TEST_CFA_RANDOM_NUM: 1 | |
TEST_CFA_FIX_DB: postgresql | |
TEST_CFA_FIX_ORM: prisma | |
- run: yarn test | |
env: | |
TEST_CFA_RANDOM_NUM: 1 | |
TEST_CFA_FIX_DB: mysql | |
TEST_CFA_FIX_ORM: typeorm | |
- run: yarn test | |
env: | |
TEST_CFA_RANDOM_NUM: 1 | |
TEST_CFA_FIX_DB: sqlite | |
- run: yarn test | |
if: github.event_name == 'schedule' | |
env: | |
TEST_CFA_RANDOM_NUM: 5 | |
# - uses: mxschmitt/action-tmate@v3 | |
# if: ${{ failure() }} | |
test-win: | |
name: 'Test on Node:${{ matrix.node-version }} OS:windows-latest' | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
node-version: [16] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: setup Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: 'node_modules' | |
key: ${{ runner.os }}-node-v${{ matrix.node-version }}-yarn-${{ hashFiles('yarn.lock') }}-3 | |
- run: echo 'network-timeout 1000000' >> ~/.yarnrc | |
- run: yarn --frozen-lockfile --network-timeout 1000000 | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
- run: yarn build | |
- run: yarn typecheck | |
- run: yarn test | |
env: | |
TEST_CFA_RANDOM_NUM: 1 | |
TEST_CFA_FIX_DB: sqlite | |
- run: yarn test | |
if: github.event_name == 'schedule' | |
env: | |
TEST_CFA_RANDOM_NUM: 5 | |
TEST_CFA_FIX_DB: sqlite | |
release: | |
runs-on: ubuntu-latest | |
needs: [test, test-win] | |
if: startsWith(github.ref, 'refs/tags/v') | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Use Node.js | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: 'node_modules' | |
key: ${{ runner.os }}-node-v16-yarn-${{ hashFiles('yarn.lock') }} | |
- run: echo 'network-timeout 1000000' >> ~/.yarnrc | |
- run: yarn --frozen-lockfile --network-timeout 1000000 | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
- run: yarn build | |
- run: | | |
VERSION="$(node -e 'console.log(process.argv[1].match(/^refs\/tags\/v(\d+\.\d+\.\d+)$/)[1])' "${{ github.ref }}")" | |
node -e 'console.log(JSON.stringify({...require("./package.json"),version:process.argv[1]}, null, 2))' "$VERSION" | tee ./tmp-package.json | |
mv ./tmp-package.json ./package.json | |
- run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |