From 2f79e7380c5912d961aa1594c157e116e097d9a7 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Mon, 25 Nov 2024 13:53:47 -0700 Subject: [PATCH 1/5] quality: parameterize test-and-lint workflow to accept SDK and test data branches --- .github/workflows/lint-test-sdk.yml | 32 +++++++++++++++++-- .../java/cloud/eppo/BaseEppoClientTest.java | 7 +++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint-test-sdk.yml b/.github/workflows/lint-test-sdk.yml index be8b74f..b51387e 100644 --- a/.github/workflows/lint-test-sdk.yml +++ b/.github/workflows/lint-test-sdk.yml @@ -5,12 +5,38 @@ on: paths: - '**/*' push: - branches: [main] + branches: [main, tp/**] + + workflow_dispatch: + 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 + + 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: ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }} ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }} CI: true + SDK_BRANCH: ${{ inputs.sdk_branch || github.head_ref || github.ref_name || 'main' }} + TEST_DATA_BRANCH: ${{ inputs.test_data_branch || 'main' }} jobs: lint-test-sdk: @@ -21,6 +47,8 @@ jobs: steps: - uses: actions/checkout@v4 with: + repository: Eppo-exp/sdk-common-jdk + ref: ${{ env.SDK_BRANCH }} fetch-depth: 0 - name: Set up JDK ${{ matrix.java-version }} @@ -32,4 +60,4 @@ jobs: gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }} - name: Run tests - run: make test + run: make test branchName=${TEST_DATA_BRANCH} diff --git a/src/test/java/cloud/eppo/BaseEppoClientTest.java b/src/test/java/cloud/eppo/BaseEppoClientTest.java index 6547268..6aa6e74 100644 --- a/src/test/java/cloud/eppo/BaseEppoClientTest.java +++ b/src/test/java/cloud/eppo/BaseEppoClientTest.java @@ -39,8 +39,13 @@ public class BaseEppoClientTest { private static final Logger log = LoggerFactory.getLogger(BaseEppoClientTest.class); private static final String DUMMY_FLAG_API_KEY = "dummy-flags-api-key"; // Will load flags-v1 + + // Use the branch specified by env variable `TEST_DATA_BRANCH`. + private static final String TEST_BRANCH = System.getenv("TEST_DATA_BRANCH"); private static final String TEST_HOST = - "https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile"; + "https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile/" + + (TEST_BRANCH != null ? "b/" + TEST_BRANCH : ""); + private final ObjectMapper mapper = new ObjectMapper().registerModule(AssignmentTestCase.assignmentTestCaseModule()); From 0ec95322020c777d69fdf6dd966d22fedb0b408e Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Mon, 25 Nov 2024 14:02:13 -0700 Subject: [PATCH 2/5] don't fail on rm --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f5041c8..2f0a787 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ test-data: mkdir -p ${tempDir} git clone -b ${branchName} --depth 1 --single-branch ${githubRepoLink} ${gitDataDir} cp -r ${gitDataDir}/ufc ${testDataDir} - rm ${testDataDir}/ufc/bandit-tests/*.dynamic-typing.json + rm -f ${testDataDir}/ufc/bandit-tests/*.dynamic-typing.json || true rm -rf ${tempDir} .PHONY: test From 9f0108f2712316ba5e4f0431c725ca24a7dafd45 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Tue, 26 Nov 2024 11:00:41 -0700 Subject: [PATCH 3/5] cleaner string --- src/test/java/cloud/eppo/BaseEppoClientTest.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/cloud/eppo/BaseEppoClientTest.java b/src/test/java/cloud/eppo/BaseEppoClientTest.java index 6aa6e74..8b9916d 100644 --- a/src/test/java/cloud/eppo/BaseEppoClientTest.java +++ b/src/test/java/cloud/eppo/BaseEppoClientTest.java @@ -40,11 +40,12 @@ public class BaseEppoClientTest { private static final Logger log = LoggerFactory.getLogger(BaseEppoClientTest.class); private static final String DUMMY_FLAG_API_KEY = "dummy-flags-api-key"; // Will load flags-v1 - // Use the branch specified by env variable `TEST_DATA_BRANCH`. + // Use branch if specified by env variable `TEST_DATA_BRANCH`. private static final String TEST_BRANCH = System.getenv("TEST_DATA_BRANCH"); + private static final String TEST_HOST_BASE = + "https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile"; private static final String TEST_HOST = - "https://us-central1-eppo-qa.cloudfunctions.net/serveGitHubRacTestFile/" - + (TEST_BRANCH != null ? "b/" + TEST_BRANCH : ""); + TEST_HOST_BASE + (TEST_BRANCH != null ? "/b/" + TEST_BRANCH : ""); private final ObjectMapper mapper = new ObjectMapper().registerModule(AssignmentTestCase.assignmentTestCaseModule()); From 5d3593eba76504a136dee10c3e1a9541e9a0a7dd Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Tue, 26 Nov 2024 11:05:11 -0700 Subject: [PATCH 4/5] inputs not needed for workflow_dispatch --- .github/workflows/lint-test-sdk.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/lint-test-sdk.yml b/.github/workflows/lint-test-sdk.yml index b51387e..e276d35 100644 --- a/.github/workflows/lint-test-sdk.yml +++ b/.github/workflows/lint-test-sdk.yml @@ -8,16 +8,6 @@ on: branches: [main, tp/**] workflow_dispatch: - 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 workflow_call: inputs: From d429c0ec82924c60838cfeef20a56c7bb47a8c45 Mon Sep 17 00:00:00 2001 From: Ty Potter Date: Tue, 3 Dec 2024 09:33:23 -0700 Subject: [PATCH 5/5] remove temp trigger --- .github/workflows/lint-test-sdk.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-test-sdk.yml b/.github/workflows/lint-test-sdk.yml index e276d35..a3596e9 100644 --- a/.github/workflows/lint-test-sdk.yml +++ b/.github/workflows/lint-test-sdk.yml @@ -5,7 +5,7 @@ on: paths: - '**/*' push: - branches: [main, tp/**] + branches: [main] workflow_dispatch: