ci: allow publishing to the public npm registry #10
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: tests | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
services: | |
# https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_USER: sutando | |
POSTGRES_PASSWORD: sutando | |
POSTGRES_DB: sutando_test | |
ports: | |
# will assign a random free host port | |
- 5432/tcp | |
# needed because the postgres container does not provide a healthcheck | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
# https://github.community/t5/GitHub-Actions/github-actions-cannot-connect-to-mysql-service/td-p/30611# | |
mysql: | |
image: mysql:5.7 | |
env: | |
MYSQL_ROOT_PASSWORD: password | |
MYSQL_DATABASE: sutando_test | |
ports: | |
- 3306 | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run tests | |
run: pnpm test | |
env: | |
MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }} | |
MYSQL_PASSWORD: password | |
POSTGRES_HOST: localhost | |
POSTGRES_USER: sutando | |
POSTGRES_PASSWORD: sutando | |
POSTGRES_PORT: ${{ job.services.postgres.ports['5432'] }} |