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

quality: parameterize branch names and make test #96

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 30 additions & 3 deletions .github/workflows/lint-test-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,37 @@ on:
paths:
- '**/*'

workflow_dispatch:

workflow_call:
inputs:
test_data_branch:
type: string
description: The branch in sdk-test-data to target for testcase files
required: false
default: main
sdk_branch:
type: string
description: The branch of the SDK to test
required: false

env:
SDK_BRANCH_NAME: ${{ inputs.sdk_branch || github.head_ref || github.ref_name || 'main' }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want a fallback to main here? I would think merges to main would be covered by github.ref_name, wouldn't it? If that's the case, it might make sense to throw an error if inputs.sdk_branch || github.head_ref || github.ref_name result in an empty $SDK_BRANCH_NAME since that would indicate something was wrong with the configuration.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right that the main fallback here is superfluous. Looking at Actions/checkout readme and code, the ref will be computed as the triggering branch or the default branch if ref is omitted or is a blank string.

The checkout action will throw an error when the refspec doesn't exist, stopping the workflow and displays an error message indicating as much. I'm not sure throwing our own error here would add much, to be honest, but I am trying to get these all hooked up so I can move on to the SDK packaging and integration testing so I may be biased.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The checkout action will throw an error when the refspec doesn't exist

Ah, right. This is a good callout. Okay, cool.

TEST_DATA_BRANCH_NAME: ${{ inputs.test_data_branch || 'main' }}

jobs:
lint-test-sdk:
runs-on: ubuntu-latest
steps:
- name: Display Testing Details
run: |
echo "Running SDK Test using"
echo "Test Data: sdk-test-data@${TEST_DATA_BRANCH_NAME}"
echo "SDK Branch: js-client-sdk@${SDK_BRANCH_NAME}"
- uses: actions/checkout@v2
with:
repository: Eppo-exp/js-client-sdk
ref: ${{ env.SDK_BRANCH_NAME }}
- name: Use Node.js
uses: actions/setup-node@v1
with:
Expand All @@ -17,21 +43,22 @@ jobs:
with:
path: './node_modules'
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('./yarn.lock') }}
- name: 'Set up GCP SDK for downloading test data'
uses: 'google-github-actions/setup-gcloud@v0'
- name: Install SDK dependencies
run: yarn --frozen-lockfile
working-directory: ./
- name: Check code with eslint
run: npx eslint '**/*.{ts,tsx}'
working-directory: ./
- name: Run tests
run: yarn test
run: make test branchName=${{ env.TEST_DATA_BRANCH_NAME }}
working-directory: ./
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
repository: Eppo-exp/js-client-sdk
ref: ${{ env.SDK_BRANCH_NAME }}
- name: Use Node.js
uses: actions/setup-node@v1
with:
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,8 @@ prepare: test-data
yarn tsc
yarn webpack
yarn api-extractor run --local

## test
.PHONY: test
test: test test-data
yarn test:unit
Loading