-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf2ce10
Showing
10 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Start FerretDB instance | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
name: Start FerretDB | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Start FerretDB | ||
uses: ./ | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- run: npm install | ||
- run: npm test | ||
|
||
custom-port: | ||
name: Start FerretDB on custom port | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Start FerretDB | ||
uses: ./ | ||
with: | ||
ferretdb-port: 12345 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- run: npm install | ||
- run: PORT=12345 npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Changelog | ||
|
||
## 1.0.0 - 2019-12-17 | ||
|
||
### Added | ||
|
||
- `1.0.0` release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM docker:stable | ||
COPY start-ferretdb.sh /start-ferretdb.sh | ||
RUN chmod +x /start-ferretdb.sh | ||
ENTRYPOINT ["/start-ferretdb.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2023 j&s-soft GmbH | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# FerretDB GitHub Action | ||
|
||
## Introduction | ||
|
||
This GitHub Action starts a FerretDB instance and a connected PostgreSQL database. You can configure a custom port using the `ferretdb-port` input, by default it is the default MongoDB port `27017`. | ||
|
||
The FerretDB version can be specified using the `ferretdb-version` input. The default version is `latest`. You can find all available FerretDB versions on [GitHub](https://github.com/FerretDB/FerretDB/releases). | ||
|
||
## Usage | ||
|
||
```yaml | ||
name: Run tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Git checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Start FerretDB | ||
uses: js-soft/ferretdb-github-action@1.8.0 | ||
with: | ||
ferretdb-version: 0.8.1 | ||
|
||
- run: npm ci | ||
- run: npm test | ||
``` | ||
## License | ||
[MIT](LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: "FerretDB in GitHub Actions" | ||
description: "Start a FerretDB instance" | ||
|
||
branding: | ||
icon: "database" | ||
color: "blue" | ||
|
||
inputs: | ||
ferretdb-version: | ||
description: 'FerretDB version to use (default "latest")' | ||
required: false | ||
default: "latest" | ||
|
||
ferretdb-port: | ||
description: "FerretDB port to use (default 27017)" | ||
required: false | ||
default: "27017" | ||
|
||
runs: | ||
using: "docker" | ||
image: "Dockerfile" | ||
args: | ||
- ${{ inputs.ferretdb-version }} | ||
- ${{ inputs.ferretdb-port }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "@js-soft/ferretdb-github-action", | ||
"version": "1.0.0", | ||
"description": "FerretDB GitHub Action", | ||
"keywords": [ | ||
"github", | ||
"github-action", | ||
"ferretdb" | ||
], | ||
"homepage": "https://github.com/js-soft/ferretdb-github-action", | ||
"bugs": { | ||
"url": "https://github.com/js-soft/ferretdb-github-action/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/js-soft/ferretdb-github-action.git" | ||
}, | ||
"license": "MIT", | ||
"author": "Julian König <julian.koenig@js-soft.com>", | ||
"scripts": { | ||
"test": "uvu" | ||
}, | ||
"devDependencies": { | ||
"expect": "~29.3.1", | ||
"mongoose": "~6.7.3", | ||
"uvu": "~0.5.6" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/sh | ||
|
||
FERRETDB_VERSION=$1 | ||
FERRETDB_PORT=$2 | ||
|
||
echo "Starting FerretDB version ${FERRETDB_VERSION} on port ${FERRETDB_PORT}" | ||
|
||
docker network create ferretdb | ||
|
||
docker run --network ferretdb --name postgres \ | ||
-e POSTGRES_USER=username \ | ||
-e POSTGRES_PASSWORD=password \ | ||
-e POSTGRES_DB=ferretdb \ | ||
-d postgres | ||
|
||
docker run --network ferretdb --name ferretdb \ | ||
-p $FERRETDB_PORT:27017 \ | ||
-e FERRETDB_POSTGRESQL_URL=postgres://username:password@postgres:5432/ferretdb \ | ||
-d ghcr.io/ferretdb/ferretdb:${FERRETDB_VERSION} | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error starting FerretDB Docker container" | ||
exit 2 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict" | ||
|
||
const { test } = require("uvu") | ||
const { expect } = require("expect") | ||
const Mongoose = require("mongoose") | ||
|
||
const PORT = process.env.PORT ?? 27017 | ||
|
||
test("connects to FerretDB", async () => { | ||
const connection = await Mongoose.createConnection(`mongodb://localhost:${PORT}`).asPromise() | ||
await connection.close() | ||
}) | ||
|
||
test("fails to connect to non-existent FerretDB instance", async () => { | ||
await expect( | ||
Mongoose.connect(`mongodb://localhost:${parseInt(PORT) + 1}`, { | ||
connectTimeoutMS: 1000, | ||
serverSelectionTimeoutMS: 1000, | ||
}) | ||
).rejects.toThrow() | ||
}) | ||
|
||
test.run() |