Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Jan 16, 2024
1 parent 36bac27 commit fbf0bb1
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .github/actions/baas-test-server/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"parserOptions": {
"sourceType": "module"
}
}
41 changes: 8 additions & 33 deletions .github/actions/baas-test-server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,15 @@ inputs:
default: master
githash:
description: Specific githash to use when starting the server (this is used instead of branch if provided)
# outputs:
# container-id:
# description: The id of the container created
# value: ${{ steps.baasaas-start.outputs.container-id }}
# baas-url:
# description: The url of the BaaS server created
# value: ${{ steps.baasaas-start.outputs.baas-url }}
# mongo-url:
# description: The url of the MongoDB instance backing the server created
# value: ${{ steps.baasaas-start.outputs.mongo-url }}
outputs:
container-id:
description: The id of the container created
baas-url:
description: The url of the BaaS server created
mongo-url:
description: The url of the MongoDB instance backing the server created

runs:
using: node20
main: start-server.js
# runs:
# using: composite
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: 20
# cache: npm
# - shell: bash
# run: npm ci --ignore-scripts
# - shell: bash
# run: npx baas-test-server baasaas start ${{ inputs.githash }} --branch ${{ inputs.branch }}
# id: baasaas-start
# env:
# BAASAAS_KEY: ${{ inputs.baasaas-key }}
# # Using another action to create a post step, since "composite" actions doesn't support those
# # See https://github.com/actions/runner/issues/1478
# - name: Stop server
# uses: TLizer/action-with-post-step@v1
# with:
# main: echo 'Nothing to do right now'
# post: npx baas-test-server baasaas start ${{ inputs.githash }} --branch ${{ inputs.branch }}

post: stop-server.js
22 changes: 20 additions & 2 deletions .github/actions/baas-test-server/start-server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
import cp from "child_process";
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2024 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

cp.execSync("ls");
import cp from "node:child_process";

cp.execSync("npx baas-test-server baasaas start", { stdio: "inherit" });
21 changes: 21 additions & 0 deletions .github/actions/baas-test-server/stop-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2024 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

import cp from "node:child_process";

cp.execSync("npx baas-test-server baasaas stop", { stdio: "inherit" });
14 changes: 13 additions & 1 deletion .github/workflows/test-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node version
uses: actions/setup-node@v3
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Start BaaS test server
id: baas
uses: ./.github/actions/baas-test-server
- run: curl ${{ steps.baas.outputs.baas-url }}/api/private/v1.0/version
with:
apiKey: ${{ secrets.BAASAAS_KEY }}
branch: ${{ inputs.branch }}
githash: ${{ inputs.githash }}
- name: Perform a request to the server
run: curl ${{ steps.baas.outputs.baas-url }}/api/private/v1.0/version
7 changes: 5 additions & 2 deletions integration-tests/baas-test-server/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ yargs(hideBin(process.argv))
.command(
["start [githash]"],
"Start a container on the BaaSaaS service",
(yargs) => yargs.positional("githash", { type: "string" }).option("branch", { default: "master" }),
(yargs) =>
yargs
.positional("githash", { type: "string", default: gha.getInput("githash") ?? undefined })
.option("branch", { default: gha.getInput("branch") || "master" }),
wrapCommand(async (argv) => {
await printUserInfo();
const container = await baasaas.startContainer(
Expand All @@ -158,7 +161,7 @@ yargs(hideBin(process.argv))
.command(
["stop [id]"],
"Stop a container running on the BaaSaaS service",
(yargs) => yargs.positional("id", { type: "string" }),
(yargs) => yargs.positional("id", { type: "string", default: gha.getState("container-id") }),
wrapCommand(async (argv) => {
await printUserInfo();
if (argv.id) {
Expand Down

0 comments on commit fbf0bb1

Please sign in to comment.