-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
694 additions
and
446 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,84 @@ | ||
name: incentives-code-tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- staging | ||
- master | ||
|
||
jobs: | ||
check: | ||
name: check for changes in incentives | ||
outputs: | ||
run_incentives_tests: ${{ steps.check_files.outputs.run_incentives_tests }} | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: check modified app folder | ||
id: check_files | ||
run: | | ||
echo "=============== list modified files ===============" | ||
git diff --name-only HEAD^ HEAD | ||
echo "========== check paths of modified files ==========" | ||
git diff --name-only HEAD^ HEAD > files.txt | ||
echo "run_incentives_tests=false" >>$GITHUB_OUTPUT | ||
while IFS= read -r file | ||
do | ||
echo $file | ||
if [[ $file == src/incentives/* ]]; then | ||
echo "run_incentives_tests=true" >>$GITHUB_OUTPUT | ||
fi | ||
done < files.txt | ||
drive: | ||
name: incentives code tests | ||
needs: [check] | ||
if: needs.check.outputs.run_incentives_tests == 'true' | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: src/incentives | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/[email protected] | ||
|
||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/[email protected] | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_CREDENTIALS }} | ||
|
||
- name: Set up gcloud Cloud SDK environment | ||
uses: google-github-actions/[email protected] | ||
|
||
- name: Add .env files | ||
run: | | ||
gcloud secrets versions access latest --secret="sta-env-incentives" > .env | ||
gcloud secrets versions access latest --secret="prod-env-incentives" > .env | ||
- name: Node setup | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Install requirements | ||
run: npm install | ||
|
||
- name: Run tests and collect coverage | ||
run: npm run test | ||
continue-on-error: true | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
Oops, something went wrong.