Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit bf2ce10

Browse files
committed
chore: initial commit
0 parents  commit bf2ce10

10 files changed

Lines changed: 206 additions & 0 deletions

File tree

.github/workflows/main.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Start FerretDB instance
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Start FerretDB
8+
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Start FerretDB
15+
uses: ./
16+
17+
- name: Use Node.js
18+
uses: actions/setup-node@v3
19+
with:
20+
node-version: 18
21+
22+
- run: npm install
23+
- run: npm test
24+
25+
custom-port:
26+
name: Start FerretDB on custom port
27+
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
- name: Start FerretDB
34+
uses: ./
35+
with:
36+
ferretdb-port: 12345
37+
38+
- name: Use Node.js
39+
uses: actions/setup-node@v3
40+
with:
41+
node-version: 18
42+
43+
- run: npm install
44+
- run: PORT=12345 npm test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
package-lock.json

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 1.0.0 - 2019-12-17
4+
5+
### Added
6+
7+
- `1.0.0` release

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM docker:stable
2+
COPY start-ferretdb.sh /start-ferretdb.sh
3+
RUN chmod +x /start-ferretdb.sh
4+
ENTRYPOINT ["/start-ferretdb.sh"]

LICENSE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2023 j&s-soft GmbH
2+
3+
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:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
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.

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# FerretDB GitHub Action
2+
3+
## Introduction
4+
5+
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`.
6+
7+
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).
8+
9+
## Usage
10+
11+
```yaml
12+
name: Run tests
13+
14+
on: [push]
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Git checkout
22+
uses: actions/checkout@v3
23+
24+
- name: Use Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: 18
28+
29+
- name: Start FerretDB
30+
uses: js-soft/ferretdb-github-action@1.8.0
31+
with:
32+
ferretdb-version: 0.8.1
33+
34+
- run: npm ci
35+
- run: npm test
36+
```
37+
38+
## License
39+
40+
[MIT](LICENSE)

action.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "FerretDB in GitHub Actions"
2+
description: "Start a FerretDB instance"
3+
4+
branding:
5+
icon: "database"
6+
color: "blue"
7+
8+
inputs:
9+
ferretdb-version:
10+
description: 'FerretDB version to use (default "latest")'
11+
required: false
12+
default: "latest"
13+
14+
ferretdb-port:
15+
description: "FerretDB port to use (default 27017)"
16+
required: false
17+
default: "27017"
18+
19+
runs:
20+
using: "docker"
21+
image: "Dockerfile"
22+
args:
23+
- ${{ inputs.ferretdb-version }}
24+
- ${{ inputs.ferretdb-port }}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "@js-soft/ferretdb-github-action",
3+
"version": "1.0.0",
4+
"description": "FerretDB GitHub Action",
5+
"keywords": [
6+
"github",
7+
"github-action",
8+
"ferretdb"
9+
],
10+
"homepage": "https://github.com/js-soft/ferretdb-github-action",
11+
"bugs": {
12+
"url": "https://github.com/js-soft/ferretdb-github-action/issues"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/js-soft/ferretdb-github-action.git"
17+
},
18+
"license": "MIT",
19+
"author": "Julian König <julian.koenig@js-soft.com>",
20+
"scripts": {
21+
"test": "uvu"
22+
},
23+
"devDependencies": {
24+
"expect": "~29.3.1",
25+
"mongoose": "~6.7.3",
26+
"uvu": "~0.5.6"
27+
},
28+
"engines": {
29+
"node": ">=8"
30+
}
31+
}

start-ferretdb.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/sh
2+
3+
FERRETDB_VERSION=$1
4+
FERRETDB_PORT=$2
5+
6+
echo "Starting FerretDB version ${FERRETDB_VERSION} on port ${FERRETDB_PORT}"
7+
8+
docker network create ferretdb
9+
10+
docker run --network ferretdb --name postgres \
11+
-e POSTGRES_USER=username \
12+
-e POSTGRES_PASSWORD=password \
13+
-e POSTGRES_DB=ferretdb \
14+
-d postgres
15+
16+
docker run --network ferretdb --name ferretdb \
17+
-p $FERRETDB_PORT:27017 \
18+
-e FERRETDB_POSTGRESQL_URL=postgres://username:password@postgres:5432/ferretdb \
19+
-d ghcr.io/ferretdb/ferretdb:${FERRETDB_VERSION}
20+
21+
if [ $? -ne 0 ]; then
22+
echo "Error starting FerretDB Docker container"
23+
exit 2
24+
fi

test/test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use strict"
2+
3+
const { test } = require("uvu")
4+
const { expect } = require("expect")
5+
const Mongoose = require("mongoose")
6+
7+
const PORT = process.env.PORT ?? 27017
8+
9+
test("connects to FerretDB", async () => {
10+
const connection = await Mongoose.createConnection(`mongodb://localhost:${PORT}`).asPromise()
11+
await connection.close()
12+
})
13+
14+
test("fails to connect to non-existent FerretDB instance", async () => {
15+
await expect(
16+
Mongoose.connect(`mongodb://localhost:${parseInt(PORT) + 1}`, {
17+
connectTimeoutMS: 1000,
18+
serverSelectionTimeoutMS: 1000,
19+
})
20+
).rejects.toThrow()
21+
})
22+
23+
test.run()

0 commit comments

Comments
 (0)