forked from athenekilta/ilmomasiina
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up vitest, Node 18, first tests * Deterministic test data, clear DB before each test * More tests for GET requests * Run tests in Actions workflow * Remove --ignore-scripts to ensure bcrypt builds * Fix test runs with fresh database * setup pnpm correctly and bump it --------- Co-authored-by: Kalle Ahlström <[email protected]>
- Loading branch information
1 parent
cc310ba
commit bb14cb8
Showing
24 changed files
with
2,147 additions
and
996 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# This file contains the bare minimum settings to test Ilmomasiina. | ||
# Database settings are not set here, as your setup for that may vary. | ||
|
||
|
||
# Database settings | ||
|
||
# Choose mysql or postgres | ||
#DB_DIALECT=<mysql|postgres> | ||
#DB_HOST=localhost | ||
#DB_PORT=<3306|5432> | ||
#DB_USER=ilmo_user | ||
#DB_PASSWORD=password | ||
#DB_DATABASE=ilmomasiina | ||
#DB_SSL=false | ||
|
||
|
||
# Authentication secrets | ||
|
||
# Set both of these to different secure random strings. | ||
# You can generate one with the command: | ||
# openssl rand -hex 32 | ||
NEW_EDIT_TOKEN_SECRET=insecure_but_that_is_ok_in_testing_1 | ||
FEATHERS_AUTH_SECRET=insecure_but_that_is_ok_in_testing_2 | ||
|
||
|
||
# Mail settings | ||
|
||
# Mail sender | ||
MAIL_FROM=<[email protected]> | ||
|
||
|
||
# URL settings | ||
|
||
# Canonical base URL for the app. Used by the backend. | ||
# Include $PATH_PREFIX, but NOT a final "/". | ||
# e.g. "http://example.com" or "http://example.com/ilmo" | ||
BASE_URL=http://localhost:3000 | ||
|
||
|
||
# Branding settings | ||
|
||
# Website strings (requires website rebuild) | ||
BRANDING_HEADER_TITLE_TEXT=Ilmomasiina | ||
BRANDING_FOOTER_GDPR_TEXT=Tietosuoja | ||
BRANDING_FOOTER_GDPR_LINK=http://example.com/privacy | ||
BRANDING_FOOTER_HOME_TEXT=Example.com | ||
BRANDING_FOOTER_HOME_LINK=http://example.com | ||
[email protected] | ||
|
||
# Email strings | ||
BRANDING_MAIL_FOOTER_TEXT=Ilmomasiina test email footer | ||
BRANDING_MAIL_FOOTER_LINK=https://example.com | ||
|
||
# iCalendar exported calendar name | ||
BRANDING_ICAL_CALENDAR_NAME=Ilmomasiina |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
name: Lint & test | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
pull_request: | ||
branches: [dev] | ||
types: [synchronize, opened, reopened, ready_for_review] | ||
workflow_call: | ||
|
||
jobs: | ||
lint: | ||
name: ESLint | ||
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
|
||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run ESLint | ||
run: npm run lint | ||
|
||
typecheck: | ||
name: Type checking | ||
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
steps: | ||
|
||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run type checking | ||
run: npm run typecheck | ||
|
||
test: | ||
name: Tests | ||
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
services: | ||
postgres: | ||
image: postgres:16 | ||
env: | ||
POSTGRES_PASSWORD: testpass | ||
POSTGRES_DB: testdb | ||
ports: | ||
- 5432:5432 | ||
# https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
|
||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Run tests | ||
run: | | ||
cp .env.test.example .env.test | ||
npm run test | ||
# Non-database test variables are kept in a separate file | ||
env: | ||
DB_DIALECT: postgres | ||
DB_HOST: localhost | ||
DB_USER: postgres | ||
DB_PASSWORD: testpass | ||
DB_DATABASE: testdb | ||
THIS_IS_A_TEST_DB_AND_CAN_BE_WIPED: 1 |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16 | ||
18 |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,10 @@ | |
"private": true, | ||
"license": "MIT", | ||
"engines": { | ||
"node": "^16", | ||
"node": "^18", | ||
"npm": "^7" | ||
}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
"bootstrap": "pnpm install", | ||
"clean": "pnpm run -r clean", | ||
|
@@ -37,7 +38,6 @@ | |
"eslint-plugin-react": "^7.33.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-simple-import-sort": "^12.0.0", | ||
"pnpm": "^8.15.3", | ||
"typescript": "~5.2.2" | ||
}, | ||
"browserslist": { | ||
|
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
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
Oops, something went wrong.