Skip to content

Commit

Permalink
Trying that again with modified script
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewTurk247 committed Jun 15, 2024
1 parent 0b50b2f commit 7cdcb6e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 12 deletions.
66 changes: 55 additions & 11 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ on:
pull_request:
workflow_dispatch:

env:
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}

jobs:
buildandtest:
name: Build and Test Swift Package
Expand All @@ -38,16 +35,63 @@ jobs:
firebase emulators:exec 'set -o pipefail && xcodebuild test -project UITests.xcodeproj -scheme TestApp -destination "platform=iOS Simulator,name=iPhone 15 Pro" -resultBundlePath UITests.xcresult -derivedDataPath ".derivedData" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcbeautify'
testandcoverage:
name: Build and Test npm Package
uses: StanfordBDHG/.github/.github/workflows/npm-test-and-coverage.yml@v2
secrets:
token: ${{ secrets.CODECOV_TOKEN }}
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
with:
working-directory: spezi-invitation-code
setup-firebase-emulator: true
runs-on: ubuntu-latest
defaults:
run:
working-directory: spezi-invitation-code
steps:
- uses: actions/checkout@v4
- name: Check environment
run: |
echo "env.selfhosted: ${{ env.selfhosted }}"
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: 'spezi-invitation-code/package-lock.json'
- name: Cache Firebase Emulators
if: ${{ !env.selfhosted && inputs.setup-firebase-emulator }}
uses: actions/cache@v4
with:
path: ~/.cache/firebase/emulators
key: ${{ runner.os }}-${{ runner.arch }}-firebase-emulators-${{ hashFiles('~/.cache/firebase/emulators/**') }}
- name: Setup Java
if: ${{ !env.selfhosted && inputs.setup-firebase-emulator }}
uses: actions/setup-java@v4
with:
distribution: 'microsoft'
java-version: '17'
- name: Install Firebase CLI Tools
if: ${{ !env.selfhosted && inputs.setup-firebase-emulator }}
run: npm install -g firebase-tools
- name: Install Node Dependencies
run: npm ci
- name: Run the tests
run: |
if [ "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" ]; then
echo -n "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" | base64 --decode > "$RUNNER_TEMP/google-application-credentials.json"
export GOOGLE_APPLICATION_CREDENTIALS="$RUNNER_TEMP/google-application-credentials.json"
echo "Stored the Google application credentials at $GOOGLE_APPLICATION_CREDENTIALS"
fi
npm test
env:
GOOGLE_APPLICATION_CREDENTIALS_BASE64: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: ${{ always() }}
with:
token: ${{ secrets.token }}
working-directory: 'spezi-invitation-code'

- name: Clean up Google application credentials
if: ${{ always() }}
run: |
rm -rf $RUNNER_TEMP/google-application-credentials.json || true
uploadcoveragereport:
name: Upload Coverage Report
needs: [buildandtest, buildandtestuitests]
needs: [buildandtest, buildandtestuitests, testandcoverage]
uses: StanfordSpezi/.github/.github/workflows/create-and-upload-coverage-report.yml@v2
with:
coveragereports: SpeziFirebase-Package.xcresult UITests.xcresult
Expand Down
3 changes: 2 additions & 1 deletion spezi-invitation-code/tests/invitationCodeVerifier.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ describe("InvitationCodeVerifier", () => {
let firestore;

beforeAll(() => {
const credentials = JSON.parse(Buffer.from(process.env.GOOGLE_APPLICATION_CREDENTIALS_BASE64, "base64").toString("utf8"));
const credentialsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
const credentials = require(credentialsPath);
admin.initializeApp({credential: admin.credential.cert(credentials)});
verifier = new InvitationCodeVerifier();
firestore = admin.firestore();
Expand Down

0 comments on commit 7cdcb6e

Please sign in to comment.