From a9d20d05221cff1673eb8baed319fabb34406c6c Mon Sep 17 00:00:00 2001 From: Skyler Calaman <54462713+Blckbrry-Pi@users.noreply.github.com> Date: Wed, 6 Mar 2024 14:41:24 -0500 Subject: [PATCH] feat(CI): Create CI for testing all modules based on a known-good engine commit --- .github/workflows/test-all.yml | 42 ++++++++++++++++++++++++++++++++ modules/tokens/tests/validate.ts | 14 +++++------ tests/basic/backend.yaml | 10 ++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/test-all.yml create mode 100644 tests/basic/backend.yaml diff --git a/.github/workflows/test-all.yml b/.github/workflows/test-all.yml new file mode 100644 index 00000000..3315159c --- /dev/null +++ b/.github/workflows/test-all.yml @@ -0,0 +1,42 @@ +name: Test all modules E2E +on: + - push + +env: + CURRENT_WORKING_ENGINE_COMMIT: 920ac277dd0f5378cf8c3cc1ae414340dc6d76a6 + +jobs: + build: + runs-on: ubuntu-20.04 + steps: + # Checkout registry repo + - name: Checkout registry Repo + uses: actions/checkout@v4 + with: + path: opengb-registry + + # Get engine repo to test against + - name: Fetch engine repo + uses: actions/checkout@v4 + with: + repository: rivet-gg/opengb + ssh-key: ${{ secrets.GH_DEPLOY_KEY }} + path: opengb + + # Get a version of the engine that we know works + - name: Checkout to working commit + run: cd opengb/ && git checkout $CURRENT_WORKING_ENGINE_COMMIT + + # Install Deno to run OpenGB + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: "1.41.1" + + # Install OpenGB + - name: Install OpenGB + run: cd opengb/ && deno task cli:install + + # Run tests on all modules in the registry + - name: Run Tests for all modules + run: cd ./opengb-registry/tests/basic && opengb test diff --git a/modules/tokens/tests/validate.ts b/modules/tokens/tests/validate.ts index d475102b..c2e8b42d 100644 --- a/modules/tokens/tests/validate.ts +++ b/modules/tokens/tests/validate.ts @@ -34,23 +34,23 @@ test( test( "validate token expired", async (ctx: TestContext) => { - const { token } = await ctx.call("tokens", "create", { + const { token } = await ctx.modules.tokens.create({ type: "test", meta: { foo: "bar" }, - expireAt: new Date(Date.now() + 100).toISOString(), - }) as any; + expireAt: new Date(Date.now() + 1000).toISOString(), + }); // Token should be valid - let validateRes = await ctx.call("tokens", "validate", { + const validateRes = await ctx.modules.tokens.validate({ token: token.token, - }) as any; + }); assertEquals(token.id, validateRes.token.id); // Wait for token to expire - await new Promise((resolve) => setTimeout(resolve, 200)); + await new Promise((resolve) => setTimeout(resolve, 1100)); const error = await assertRejects(async () => { - await ctx.call("tokens", "validate", { token: token.token }) as any; + await ctx.modules.tokens.validate({ token: token.token }); }, RuntimeError); assertEquals(error.code, "TOKEN_EXPIRED"); }, diff --git a/tests/basic/backend.yaml b/tests/basic/backend.yaml new file mode 100644 index 00000000..83a2faee --- /dev/null +++ b/tests/basic/backend.yaml @@ -0,0 +1,10 @@ +registries: + default: + local: + directory: ../../modules +modules: + currency: {} + friends: {} + rate_limit: {} + tokens: {} + users: {}