-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from NineFX/github_actions
Move to GitHub Actions
- Loading branch information
Showing
8 changed files
with
230 additions
and
16 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,22 @@ | ||
name: Runs Dialyzer | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
dialyzer: | ||
runs-on: ubuntu-20.04 | ||
container: | ||
image: erlang:24-slim | ||
steps: | ||
- uses: actions/[email protected] | ||
- name: Cache PLTs | ||
id: cache-plts | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/rebar3/ | ||
key: ${{ runner.os }}-erlang-${{ hashFiles(format('{0}{1}', github.workspace, '/rebar.lock')) }} | ||
- run: apt-get update && apt-get --yes install git | ||
- run: ./rebar3 dialyzer |
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,43 @@ | ||
name: Run tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
erlang: [22, 23] | ||
mongodb: ["4.4.8", "5.0.2"] | ||
container: | ||
image: erlang:${{ matrix.erlang }} | ||
steps: | ||
- uses: actions/[email protected] | ||
- run: ./scripts/install_mongo_debian.sh ${{ matrix.mongodb }} | ||
- run: ./scripts/start_mongo_single_node.sh | ||
- run: ./scripts/start_mongo_cluster.sh | ||
- run: ./rebar3 eunit | ||
- run: ./rebar3 ct | ||
- name: Archive Replica Set Logs | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: mongodb_replica_set_logs | ||
path: rs0-logs | ||
retention-days: 1 | ||
- name: Archive Single Node Log | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: single_node.log | ||
path: single_node.log | ||
retention-days: 1 | ||
- name: CT Logs | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ct_logs | ||
path: _build/test/logs/ | ||
retention-days: 5 |
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,46 @@ | ||
name: Run tests with coverage | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
test_coverage: | ||
runs-on: ubuntu-20.04 | ||
container: | ||
image: erlang:23 | ||
steps: | ||
- uses: actions/[email protected] | ||
- run: ./scripts/install_mongo_debian.sh 5.0.2 | ||
- run: ./scripts/start_mongo_single_node.sh | ||
- run: ./scripts/start_mongo_cluster.sh | ||
- run: ./rebar3 eunit --cover --cover_export_name eunit.coverdata | ||
- run: ./rebar3 ct --cover --cover_export_name ct.coverdata | ||
- run: rebar3 cover --verbose | ||
- name: Archive Replica Set Logs | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: mongodb_replica_set_logs | ||
path: rs0-logs | ||
retention-days: 1 | ||
- name: Archive Single Node Log | ||
uses: actions/upload-artifact@v2 | ||
if: failure() | ||
with: | ||
name: single_node.log | ||
path: single_node.log | ||
retention-days: 1 | ||
- name: Coverage Report | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Coverage Report | ||
path: _build/test/cover/ | ||
retention-days: 5 | ||
- name: CT Logs | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: ct_logs | ||
path: _build/test/logs/ | ||
retention-days: 5 |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
.* | ||
!.travis.yml | ||
ebin/ | ||
deps/ | ||
logs/ | ||
|
This file was deleted.
Oops, something went wrong.
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,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
# e.g. trim 4.4.8 to 4.4 | ||
group=`echo $1 | sed 's/\(.*\)[.].*/\1/'` | ||
apt-get update | ||
apt-get --yes install gnupg wget netcat | ||
wget -qO - https://www.mongodb.org/static/pgp/server-${group}.asc | apt-key add - | ||
echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/${group} main" | tee /etc/apt/sources.list.d/mongodb-org-${group}.list | ||
apt-get update | ||
apt-get install -y mongodb-org=${1} mongodb-org-server=${1} mongodb-org-shell=${1} mongodb-org-mongos=${1} mongodb-org-tools=${1} | ||
echo "mongodb-org hold" | dpkg --set-selections | ||
echo "mongodb-org-server hold" | dpkg --set-selections | ||
echo "mongodb-org-shell hold" | dpkg --set-selections | ||
echo "mongodb-org-mongos hold" | dpkg --set-selections | ||
echo "mongodb-org-tools hold" | dpkg --set-selections | ||
mongod --version |
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,71 @@ | ||
#!/usr/bin/env bash | ||
# Based on Supercharge's MIT-licensed MongoDB GitHub Action | ||
# https://github.com/supercharge/mongodb-github-action | ||
|
||
set -ex | ||
|
||
rm -rf rs0-0 rs0-1 rs0-2 rs0-logs rs0-key | ||
mkdir -p rs0-0 rs0-1 rs0-2 rs0-logs rs0-key | ||
|
||
# Replica set key for inter-node auth | ||
echo "notsosecretkey" > rs0-key/key | ||
|
||
# MongoDB won't start if the replica set shared key is world-writable | ||
chmod 600 rs0-key/key | ||
|
||
echo "Starting replica set nodes" | ||
mongod --replSet rs0 --port 27018 --bind_ip localhost --dbpath rs0-0 --oplogSize 128 >> rs0-logs/rs0-0.log.txt & | ||
mongod --replSet rs0 --port 27019 --bind_ip localhost --dbpath rs0-1 --oplogSize 128 >> rs0-logs/rs0-1.log.txt & | ||
mongod --replSet rs0 --port 27020 --bind_ip localhost --dbpath rs0-2 --oplogSize 128 >> rs0-logs/rs0-2.log.txt & | ||
|
||
echo "Waiting on MongoDB to start on 27018" | ||
timeout 5m sh -c 'until nc -z localhost 27018; do sleep 1; done' | ||
echo "Waiting on MongoDB to start on 27019" | ||
timeout 5m sh -c 'until nc -z localhost 27019; do sleep 1; done' | ||
echo "Waiting on MongoDB to start on 27020" | ||
timeout 5m sh -c 'until nc -z localhost 27020; do sleep 1; done' | ||
|
||
# Create a replica set from the three nodes | ||
echo "Initiating replica set config" | ||
mongo --port 27018 admin --eval 'rs.initiate( | ||
{"_id": "rs0", "members": [ | ||
{"_id": 0, "host": "localhost:27018"}, | ||
{"_id": 1, "host": "localhost:27019"}, | ||
{"_id": 2, "host": "localhost:27020"}]})' | ||
|
||
echo "Waiting for replica set to come up" | ||
timeout 1m sh -c "until mongo --quiet --host rs0/localhost:27018,localhost:27019,localhost:27020 admin --eval 'rs.status()'; do sleep 1; done" | ||
|
||
# Add a user for authentication | ||
mongo --host rs0/localhost:27018,localhost:27019,localhost:27020 \ | ||
admin \ | ||
--eval 'db.createUser( | ||
{user: "rs_user", | ||
pwd: "rs_test", | ||
roles: [{role: "clusterAdmin", db: "admin"}, | ||
{role: "userAdminAnyDatabase", db: "admin"}, | ||
"readWrite"]})' | ||
|
||
# Shutdown nodes in replica set | ||
mongod --shutdown --dbpath rs0-0 | ||
mongod --shutdown --dbpath rs0-1 | ||
mongod --shutdown --dbpath rs0-2 | ||
|
||
# Restart replica set nodes with authentication enabled | ||
mongod --replSet rs0 --auth --keyFile rs0-key/key --port 27018 --bind_ip localhost --dbpath rs0-0 --oplogSize 128 >> rs0-logs/rs0-0-auth.log.txt & | ||
mongod --replSet rs0 --auth --keyFile rs0-key/key --port 27019 --bind_ip localhost --dbpath rs0-1 --oplogSize 128 >> rs0-logs/rs0-1-auth.log.txt & | ||
mongod --replSet rs0 --auth --keyFile rs0-key/key --port 27020 --bind_ip localhost --dbpath rs0-2 --oplogSize 128 >> rs0-logs/rs0-2-auth.log.txt & | ||
|
||
echo "Waiting on MongoDB to restart on 27018" | ||
timeout 5m sh -c 'until nc -z localhost 27018; do sleep 1; done' | ||
echo "Waiting on MongoDB to restart on 27019" | ||
timeout 5m sh -c 'until nc -z localhost 27019; do sleep 1; done' | ||
echo "Waiting on MongoDB to restart on 27020" | ||
timeout 5m sh -c 'until nc -z localhost 27020; do sleep 1; done' | ||
|
||
# Verify that we can auth to the restarted replica set | ||
mongo --host rs0/localhost:27018,localhost:27019,localhost:27020 \ | ||
--username rs_user \ | ||
--password rs_test \ | ||
--authenticationDatabase admin \ | ||
--eval 'db.serverStatus()' > /dev/null |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
rm -rf single_node single_node.log | ||
mkdir -p single_node | ||
|
||
echo "Starting single node" | ||
mongod --port 27017 --bind_ip localhost --dbpath single_node --oplogSize 128 > single_node.log & | ||
|
||
echo "Waiting on single node MongoDB to start on 27017" | ||
timeout 5m sh -c 'until nc -z localhost 27017; do sleep 1; done' | ||
|
||
mongo admin --eval 'db.createUser( | ||
{user: "user", | ||
pwd: "test", | ||
roles: [{role: "userAdminAnyDatabase", db: "admin"}, | ||
"readWrite"]} | ||
)' | ||
|
||
mongod --shutdown --dbpath single_node | ||
|
||
mongod --port 27017 --bind_ip localhost --dbpath single_node --oplogSize 128 >> single_node.log & | ||
|
||
echo "Waiting on single node MongoDB to restart with auth on 27017" | ||
timeout 5m sh -c 'until nc -z localhost 27017; do sleep 1; done' | ||
|
||
# Verify that we can auth to the restarted replica set | ||
mongo --username user \ | ||
--password test \ | ||
--eval 'db.serverStatus()' |