Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add jest unit testing #67

Merged
merged 40 commits into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9a54d5f
Fix .meshrc type errors
jfoo1984 Jan 13, 2024
b75a9e4
Change mesh schema script permissions
jfoo1984 Jan 13, 2024
9baaa28
Add jest
jfoo1984 Jan 13, 2024
000743b
Add test to check for valid schema
jfoo1984 Jan 13, 2024
d1411ec
Configure jest tests to run on every push
jfoo1984 Jan 13, 2024
c5ff7fe
Trigger tests
jfoo1984 Jan 13, 2024
ddf7f95
Add node setup for tests
jfoo1984 Jan 13, 2024
4eff0e6
Rename workflow and job
jfoo1984 Jan 13, 2024
29271ce
install lib curl to fix dependency installation issue
jfoo1984 Jan 13, 2024
eefce76
Rename github action file
jfoo1984 Jan 13, 2024
91ae46e
Change libcurl package name
jfoo1984 Jan 13, 2024
a7d8b1c
Need libcurl dev package
jfoo1984 Jan 13, 2024
27ea02f
search for right libcurl package
jfoo1984 Jan 13, 2024
2f3fdbe
Print linux version
jfoo1984 Jan 13, 2024
004afcf
Print linux distribution version
jfoo1984 Jan 13, 2024
409a841
run apt-get update
jfoo1984 Jan 13, 2024
45fb166
Remove libcurl search
jfoo1984 Jan 13, 2024
b75845f
Update test snapshot
jfoo1984 Jan 13, 2024
7274414
Build mesh before running tests
jfoo1984 Jan 13, 2024
2ec79e6
Add schema snapshot test and zip link query test
jfoo1984 Jan 24, 2024
d89bc0a
deps: update dependencies to latest
jfoo1984 Jan 24, 2024
3b81807
Merge branch 'main' into CZID-9015-add-snapshot-tests
jfoo1984 Jan 24, 2024
9c4579b
Use main branch of conventional commits
jfoo1984 Jan 24, 2024
cc00f12
Rename schema test
jfoo1984 Jan 24, 2024
f1cadf1
Rename schema test snapshot
jfoo1984 Jan 24, 2024
6aeff3c
Clean up whitespace in mock store
jfoo1984 Jan 24, 2024
0d22c3c
Stop pushing PR merges to staging automatically
jfoo1984 Jan 24, 2024
9374cc2
Modularize mocks in meshrc.yml
jfoo1984 Jan 24, 2024
7893dd0
Update tests to run in docker container
jfoo1984 Jan 24, 2024
8244aaa
Extract common code in tests
jfoo1984 Jan 25, 2024
f684433
Create docker network to allow tests to run in CI
jfoo1984 Jan 25, 2024
8dbb400
Add docker command to allow network to be created
jfoo1984 Jan 25, 2024
4fa7b05
Add verbose to jest for debugging
jfoo1984 Jan 25, 2024
1c10573
Switch back to run tests without docker
jfoo1984 Jan 25, 2024
694101c
Build mesh artifacts before running tests
jfoo1984 Jan 25, 2024
1764998
Run build in test command
jfoo1984 Jan 25, 2024
1963564
Build docker image for CI tests
jfoo1984 Jan 25, 2024
9c2dd99
Updates to fix tests
jfoo1984 Jan 25, 2024
63a1b5a
Change to stubbing responses to test resolvers
jfoo1984 Jan 25, 2024
250f37f
Remove mock plugin and references
jfoo1984 Jan 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chanzuckerberg/github-actions/.github/actions/conventional-commits@v1.3.2
- uses: chanzuckerberg/github-actions/.github/actions/conventional-commits@main
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since #61 was closed in favor of this PR, I am pulling this change in that was there.

5 changes: 2 additions & 3 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
on:
push:
branches:
- main
release:
types: [published]
Comment on lines +2 to +3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is in preparation for changing the release cadence. stop pushing every PR to staging


name: Deploy main to staging
jobs:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/jest-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Jest unit tests
on: push

jobs:
jest-unit-tests:
runs-on: [ARM64, self-hosted, Linux]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libcurl4-openssl-dev
- name: Build Docker image
run: |
make build
- name: Create Docker network
run: |
docker swarm init
docker network create czidnet --attachable --driver overlay
- name: Run tests in Docker container
run: |
make test
23 changes: 0 additions & 23 deletions .github/workflows/push-tests.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .meshrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ additionalResolvers:
plugins:
- csrfPrevention:
requestHeaders: ['x-graphql-yoga-csrf']
- mock:
if: "process.env.MOCKING_ENABLED != null"
initializeStore: ./tests/mocks/CZIDMockStore#initializeStore
mocks: !includes meshrc-mocks
serve:
port: 4444
endpoint: "/graphqlfed"
Expand Down
6 changes: 6 additions & 0 deletions example-queries/zip-link-query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
query ZipLinkQuery($workflowRunId: String) {
ZipLink(workflowRunId: $workflowRunId) {
url
error
}
}
Empty file modified generate_mesh_schema.py
100644 → 100755
Empty file.
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
};
4 changes: 2 additions & 2 deletions json-schemas/amrWorkflowResults.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"type": "object",
"properties": {
"quality_metrics": {
"metric_amr": {
"type": "object",
"properties": {
"total_reads": {
Expand Down Expand Up @@ -33,7 +33,7 @@
}
}
},
"report_table_data": {
"amr_hit": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align to schema returned by resolver. This was preventing the tests from running, because the schema could not be generated

"type": "array",
"items": {
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion json-schemas/mngsWorkflowResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"type": "object",
"properties": {
"tax_id": {
"type": "integer"
"type": "string"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align to schema returned by resolver. This was preventing the tests from running, because the schema could not be generated

},
"name": {
"type": "string"
Expand Down
4 changes: 4 additions & 0 deletions meshrc-mocks/zipLink.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apply: Query.ZipLink
store:
type: ZipLink
key: "{args.workflowRunId}"
Loading
Loading