-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github actions for lint and test
- Loading branch information
Showing
1 changed file
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# deploy.yml test | ||
name: Deploy analytics-reporter to cloud.gov | ||
|
||
on: | ||
push: | ||
pull-request: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
cache: 'npm' | ||
- name: Create Checksum of package.json | ||
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV" | ||
- name: Restore Cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ./node_modules | ||
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }} | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Save Cache | ||
uses: actions/cache/save@v4 | ||
id: cache | ||
with: | ||
path: ./node_modules | ||
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }} | ||
- name: Lint JavaScript | ||
run: npm run lint | ||
test: | ||
needs: lint | ||
runs-on: ubuntu-latest | ||
#Spin up postgres as a service, wait till healthy before moving on. Uses latest Postgres Version. | ||
services: | ||
postgres: | ||
image: postgres:latest | ||
env: | ||
POSTGRES_DB: analytics_reporter_test | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
ports: | ||
- 5432:5432 | ||
options: | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
- name: Code Checkout | ||
uses: actions/checkout@v4 | ||
- name: Install Node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "lts/*" | ||
cache: 'npm' | ||
- name: Create Checksum of package.json | ||
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV" | ||
- name: Restore Cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ./node_modules | ||
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }} | ||
- name: Install Dependencies | ||
run: npm install | ||
- name: Save Cache | ||
uses: actions/cache/save@v4 | ||
id: cache | ||
with: | ||
path: ./node_modules | ||
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }} | ||
- name: Run tests | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: analytics_reporter_test | ||
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }} | ||
run: npm test |