diff --git a/.github/workflows/prod_test.yml b/.github/workflows/prod_test.yml new file mode 100644 index 0000000..64379d9 --- /dev/null +++ b/.github/workflows/prod_test.yml @@ -0,0 +1,22 @@ +on: + schedule: + - cron: "0 0 * * *" + workflow_call: + +jobs: + test: + name: Test ENState 🚀 + runs-on: arc-runner-set + strategy: + fail-fast: false + matrix: + suite: [enstate.rs, worker.enstate.rs] + steps: + - run: bun install + working-directory: test + + - name: Test + run: bun test remote --rerun-each 2 + env: + REMOTE_URL: https://${{ matrix.suite }} + working-directory: test diff --git a/test/src/test_implementation.ts b/test/src/test_implementation.ts index fae29bf..e2b6874 100644 --- a/test/src/test_implementation.ts +++ b/test/src/test_implementation.ts @@ -1,6 +1,15 @@ import { describe, expect, test } from 'bun:test'; -import { Dataset } from '../data'; +import { + Dataset, + dataset_address_bulk, + dataset_address_single, + dataset_name_bulk, + dataset_name_single, + dataset_universal_bulk, + dataset_universal_single, +} from '../data'; +import { http_fetch } from './http_fetch'; export const test_implementation = , DataType extends {}>( function_name: string, @@ -17,3 +26,28 @@ export const test_implementation = , DataType } }); }; + +export const describe_for = (prefix: string, base_url: string) => { + test_implementation(`${prefix}/name`, http_fetch(`${base_url}/n/`), dataset_name_single); + test_implementation(`${prefix}/address`, http_fetch(`${base_url}/a/`), dataset_address_single); + test_implementation( + `${prefix}/universal`, + http_fetch(`${base_url}/u/`), + dataset_universal_single + ); + test_implementation( + `${prefix}/bulk/name`, + http_fetch(`${base_url}/bulk/n?`), + dataset_name_bulk + ); + test_implementation( + `${prefix}/bulk/address`, + http_fetch(`${base_url}/bulk/a?`), + dataset_address_bulk + ); + test_implementation( + `${prefix}/bulk/universal`, + http_fetch(`${base_url}/bulk/u?`), + dataset_universal_bulk + ); +}; diff --git a/test/tests/remote.spec.ts b/test/tests/remote.spec.ts new file mode 100644 index 0000000..8a33fc6 --- /dev/null +++ b/test/tests/remote.spec.ts @@ -0,0 +1,5 @@ +import { describe_for } from '../src/test_implementation'; + +const url = process.env.REMOTE_URL ?? 'https://enstate.rs'; + +describe_for(`remote (${url})`, url); diff --git a/test/tests/server.spec.ts b/test/tests/server.spec.ts index f8363d6..eb024d2 100644 --- a/test/tests/server.spec.ts +++ b/test/tests/server.spec.ts @@ -1,14 +1,7 @@ import { Subprocess } from 'bun'; import { afterAll, beforeAll } from 'bun:test'; -import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data'; -import { - dataset_address_single, - dataset_name_single, - dataset_universal_single, -} from '../data/single'; -import { http_fetch } from '../src/http_fetch'; -import { test_implementation } from '../src/test_implementation'; +import { describe_for } from '../src/test_implementation'; const TEST_RELEASE = true; @@ -57,32 +50,4 @@ afterAll(async () => { server?.kill(); }); -const PREFIX = 'server'; - -test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single); -test_implementation( - `${PREFIX}/address`, - http_fetch('http://0.0.0.0:3000/a/'), - dataset_address_single -); -test_implementation( - `${PREFIX}/universal`, - http_fetch('http://0.0.0.0:3000/u/'), - dataset_universal_single -); - -test_implementation( - `${PREFIX}/bulk/name`, - http_fetch('http://0.0.0.0:3000/bulk/n?'), - dataset_name_bulk -); -test_implementation( - `${PREFIX}/bulk/address`, - http_fetch('http://0.0.0.0:3000/bulk/a?'), - dataset_address_bulk -); -test_implementation( - `${PREFIX}/bulk/universal`, - http_fetch('http://0.0.0.0:3000/bulk/u?'), - dataset_universal_bulk -); +describe_for('server', 'http://127.0.0.1:3000'); diff --git a/test/tests/worker.spec.ts b/test/tests/worker.spec.ts index 84100ff..36229b4 100644 --- a/test/tests/worker.spec.ts +++ b/test/tests/worker.spec.ts @@ -1,14 +1,7 @@ import { Subprocess } from 'bun'; import { afterAll, beforeAll } from 'bun:test'; -import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data'; -import { - dataset_address_single, - dataset_name_single, - dataset_universal_single, -} from '../data/single'; -import { http_fetch } from '../src/http_fetch'; -import { test_implementation } from '../src/test_implementation'; +import { describe_for } from '../src/test_implementation'; let server: Subprocess<'ignore', 'pipe', 'inherit'> | undefined; @@ -44,32 +37,4 @@ afterAll(async () => { await server?.exited; }); -const PREFIX = 'worker'; - -test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single); -test_implementation( - `${PREFIX}/address`, - http_fetch('http://0.0.0.0:3000/a/'), - dataset_address_single -); -test_implementation( - `${PREFIX}/universal`, - http_fetch('http://0.0.0.0:3000/u/'), - dataset_universal_single -); - -test_implementation( - `${PREFIX}/bulk/name`, - http_fetch('http://0.0.0.0:3000/bulk/n?'), - dataset_name_bulk -); -test_implementation( - `${PREFIX}/bulk/address`, - http_fetch('http://0.0.0.0:3000/bulk/a?'), - dataset_address_bulk -); -test_implementation( - `${PREFIX}/bulk/universal`, - http_fetch('http://0.0.0.0:3000/bulk/u?'), - dataset_universal_bulk -); +describe_for('worker', 'http://127.0.0.1:3000');