Skip to content

Commit a9a327a

Browse files
authored
Merge pull request #236 from 18F/github_actions
Add github actions for lint and test
2 parents ba90f16 + da0e27b commit a9a327a

File tree

13 files changed

+837
-728
lines changed

13 files changed

+837
-728
lines changed

.circleci/config.yml

Lines changed: 0 additions & 197 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
on:
2+
push:
3+
pull_request:
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Code Checkout
10+
uses: actions/checkout@v4
11+
- name: Install Node
12+
uses: actions/setup-node@v4
13+
with:
14+
node-version: "lts/*"
15+
cache: 'npm'
16+
- name: Create Checksum of package.json
17+
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
18+
- name: Restore Cache
19+
uses: actions/cache/restore@v4
20+
with:
21+
path: ./node_modules
22+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
23+
- name: Install Dependencies
24+
run: npm install
25+
- name: Save Cache
26+
uses: actions/cache/save@v4
27+
id: cache
28+
with:
29+
path: ./node_modules
30+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
31+
- name: lint javascript
32+
run: npm run lint
33+
test:
34+
needs: lint
35+
runs-on: ubuntu-latest
36+
#Spin up postgres as a service, wait till healthy before moving on. Uses latest Postgres Version.
37+
services:
38+
postgres:
39+
image: postgres:latest
40+
env:
41+
POSTGRES_DB: analytics_reporter_test
42+
POSTGRES_USER: analytics
43+
POSTGRES_PASSWORD: 123abc
44+
ports:
45+
- 5432:5432
46+
options:
47+
--health-cmd pg_isready
48+
--health-interval 10s
49+
--health-timeout 5s
50+
--health-retries 5
51+
steps:
52+
- name: Code Checkout
53+
uses: actions/checkout@v4
54+
- name: Install Node
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: "lts/*"
58+
cache: 'npm'
59+
- name: Create Checksum of package.json
60+
run: echo PACKAGE_CHECKSUM="$(shasum package.json | awk '{ print $1 }')" >> "$GITHUB_ENV"
61+
- name: Restore Cache
62+
uses: actions/cache/restore@v4
63+
with:
64+
path: ./node_modules
65+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
66+
- name: Install Dependencies
67+
run: npm install
68+
- name: Save Cache
69+
uses: actions/cache/save@v4
70+
id: cache
71+
with:
72+
path: ./node_modules
73+
key: v1-dependencies-${{ env.PACKAGE_CHECKSUM }}
74+
- name: run tests
75+
run: npm test
76+
deploy_dev:
77+
needs:
78+
- lint
79+
- test
80+
if: github.ref == 'refs/heads/develop'
81+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
82+
with:
83+
APP_NAME: ${{ vars.APP_NAME_DEV }}
84+
DB_NAME: ${{ vars.DB_NAME_DEV }}
85+
NEW_RELIC_APP_NAME:
86+
ORGANIZATION_NAME: gsa-opp-analytics
87+
SPACE_NAME: analytics-dev
88+
secrets:
89+
CF_USERNAME: ${{ secrets.CF_USERNAME_DEV }}
90+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_DEV }}
91+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_DEV }}
92+
NEW_RELIC_LICENSE_KEY:
93+
deploy_stg:
94+
needs:
95+
- lint
96+
- test
97+
if: github.ref == 'refs/heads/staging'
98+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
99+
with:
100+
APP_NAME: ${{ vars.APP_NAME_STG }}
101+
DB_NAME: ${{ vars.DB_NAME_STG }}
102+
NEW_RELIC_APP_NAME:
103+
ORGANIZATION_NAME: gsa-opp-analytics
104+
SPACE_NAME: analytics-staging
105+
secrets:
106+
CF_USERNAME: ${{ secrets.CF_USERNAME_STG }}
107+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_STG }}
108+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_STG }}
109+
NEW_RELIC_LICENSE_KEY:
110+
deploy_prd:
111+
needs:
112+
- lint
113+
- test
114+
if: github.ref == 'refs/heads/master'
115+
uses: 18F/analytics-reporter-api/.github/workflows/deploy.yml@develop
116+
with:
117+
APP_NAME: ${{ vars.APP_NAME_PRD }}
118+
DB_NAME: ${{ vars.DB_NAME_PRD }}
119+
NEW_RELIC_APP_NAME: ${{ vars.NEW_RELIC_APP_NAME_PRD }}
120+
ORGANIZATION_NAME: gsa-opp-analytics
121+
SPACE_NAME: analytics-production
122+
secrets:
123+
CF_USERNAME: ${{ secrets.CF_USERNAME_PRD }}
124+
CF_PASSWORD: ${{ secrets.CF_PASSWORD_PRD }}
125+
API_DATA_GOV_SECRET: ${{ secrets.API_DATA_GOV_SECRET_PRD }}
126+
NEW_RELIC_LICENSE_KEY: ${{ secrets.NEW_RELIC_LICENSE_KEY_PRD }}

0 commit comments

Comments
 (0)