Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a github action to build and test project #120

Open
wants to merge 54 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
fde01c9
add nodejs github action
adrianparsons Oct 23, 2023
e49bb83
only test node versions 18.x and 20.x
adrianparsons Oct 23, 2023
1206a69
start mysql service (ubuntu comes with it)
adrianparsons Oct 23, 2023
9327fd2
temporarily change config value to default mysql root password
adrianparsons Oct 23, 2023
908618b
try establishing root password during setup
adrianparsons Oct 23, 2023
6ef255c
Revert "temporarily change config value to default mysql root password"
adrianparsons Oct 23, 2023
5401710
login to mysql as root
adrianparsons Oct 23, 2023
a6a912d
try root pw
adrianparsons Oct 23, 2023
afecce3
it can't be
adrianparsons Oct 23, 2023
218c48c
add postgres service
adrianparsons Oct 24, 2023
09abab6
only run one version of node right now, change postgres pw
adrianparsons Oct 24, 2023
be8fe6f
set password with correct var
adrianparsons Oct 24, 2023
578d3ba
POSTGRES_PASSWORD is required, also add port mapping
adrianparsons Oct 24, 2023
d4b0462
test connection with a step
adrianparsons Oct 24, 2023
fbdb4b9
gh action syntax...
adrianparsons Oct 24, 2023
441dc15
define host
adrianparsons Oct 24, 2023
6bf312f
try localhost....
adrianparsons Oct 24, 2023
74d1c42
host postgres?
adrianparsons Oct 24, 2023
2f523f1
add some health checks
adrianparsons Oct 24, 2023
f49edea
did healthcheck fix problem
adrianparsons Oct 24, 2023
f0e6067
just trying things
adrianparsons Oct 24, 2023
e34e17f
add continue-on-error, try another command
adrianparsons Oct 24, 2023
211e95e
break out cmd, make sure we're using strings
adrianparsons Oct 24, 2023
e1e8aed
try with postgres user
adrianparsons Oct 24, 2023
ff459f9
rename test output, create default db
adrianparsons Oct 24, 2023
32e6e5d
drop public schema before test
adrianparsons Oct 24, 2023
7980c5d
wrap schema with double quotes
adrianparsons Oct 24, 2023
d9862ca
this does not work like i thought it did
adrianparsons Oct 24, 2023
19f534f
bettername for step, can we get away without port?
adrianparsons Oct 24, 2023
30f1672
can we get away without port mapping
adrianparsons Oct 24, 2023
7f60da2
can we live without host?
adrianparsons Oct 24, 2023
eb7f42b
Revert "can we live without host?"
adrianparsons Oct 24, 2023
69156f1
use clearer syntax
adrianparsons Oct 24, 2023
e7fe3e3
accidentally deleted this
adrianparsons Oct 24, 2023
165a243
change value to check that tests fail
adrianparsons Oct 24, 2023
623c0fb
Revert "change value to check that tests fail"
adrianparsons Oct 24, 2023
f5a2087
use env key
adrianparsons Oct 24, 2023
4d35740
eh?
adrianparsons Oct 24, 2023
9cdc944
can use vars like this?
adrianparsons Oct 24, 2023
4f962f5
shot in the dark
adrianparsons Oct 24, 2023
cb7f7e2
nope, won't work
adrianparsons Oct 24, 2023
37a6ff3
change order of keys, better name for mysql step
adrianparsons Oct 25, 2023
a18feed
try this way of accessing env var
adrianparsons Oct 25, 2023
9de2f60
use top-level env vars more
adrianparsons Oct 25, 2023
f4777ef
more env var use
adrianparsons Oct 25, 2023
328cbba
quotes
adrianparsons Oct 25, 2023
a9c6607
use 2 node versions, use latest postgres image
adrianparsons Oct 25, 2023
deb34e0
try building docker image?
adrianparsons Oct 25, 2023
f1a5561
Revert "try building docker image?"
adrianparsons Oct 25, 2023
d4eb28d
see if this works without options
adrianparsons Oct 25, 2023
2154145
Revert "see if this works without options"
adrianparsons Oct 25, 2023
035de92
clean up github action file, reorder some steps, update and add labels
adrianparsons Nov 13, 2023
153b8f2
maybe we don't have to do this
adrianparsons Nov 13, 2023
a864c2d
clean up env var names
adrianparsons Nov 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Build and test with Node.js

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
DB_NAME: nmig_test_db
DB_PASSWORD: '0123456789'

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x]

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: ${{ env.DB_PASSWORD }}
POSTGRES_DB: ${{ env.DB_NAME }}
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Configure Postgres table
env:
PGPASSWORD: ${{ env.DB_PASSWORD }}
run: >-
psql -c 'DROP SCHEMA public'
-d $DB_NAME
-h localhost
-U postgres

- name: Start MySQL server and set root password
run: |
sudo /etc/init.d/mysql start
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '$DB_PASSWORD'" -uroot -proot

- run: npm ci
- run: npm run build
- run: npm test