Skip to content

Commit

Permalink
[chore] Add test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Warr authored and laurawarr committed Mar 29, 2023
1 parent 0525bc9 commit 28e224e
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '16'
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- run: yarn install
- run: yarn test
18 changes: 18 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on: [push]

name: Test Workflow

jobs:
dvc-code-usages:
runs-on: ubuntu-latest
name: Update code usages
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
client-id: ${{ secrets.DVC_CLIENT_ID }}
client-secret: ${{ secrets.DVC_CLIENT_SECRET }}
project-key: default
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
name: Fetch DevCycle Code Usages
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: DevCycleHQ/[email protected]
Expand Down
34 changes: 34 additions & 0 deletions test-workflow.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/******************************************************************************
* This file is used with workflow.yml is running without errors and usage data
* is sent to the DVC test org.
*
* https://app.devcycle.com/o/org_U9F8YMaTChTEndWw/p/default/variables
******************************************************************************/
// @ts-nocheck

import { initialize } from '@devcycle/devcycle-js-sdk'

// The user object needs either a user_id, or isAnonymous set to true
const user = { user_id: 'my_user' }
let dvcClient

try {
// Call initialize with the client key and a user object
// await on the features to be loaded from our servers
dvcClient = await initialize('client-123', user)
.onClientInitialized()

useDVCVariable()
} catch(ex) {
console.log('Error initializing DVC: ${ex}')
}

function useDVCVariable() {
if (!dvcClient) return

// Fetch variable values using the identifier key coupled with a default value
// The default value can be of type string, boolean, number, or object
const dvcVariableNumber = dvcClient.variable('test-feature-number', 10)
const dvcVariableString = dvcClient.variable('test-feature-string', '10')
const dvcVariableJson = dvcClient.variable('test-feature-json', {})
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"esModuleInterop": true,
"strict": true
},
"include": ["src/**/*"]
"include": ["src/**/*"],
"exclude": ["test-workflow.ts"]
}

0 comments on commit 28e224e

Please sign in to comment.