forked from travist/resourcejs
-
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
Showing
15 changed files
with
8,000 additions
and
2,641 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
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,9 @@ | ||
FROM mongo:5.0.15 | ||
|
||
VOLUME /data | ||
EXPOSE 27001 27002 27003 | ||
|
||
COPY docker-entrypoint.sh /usr/local/bin/ | ||
RUN chmod +x /usr/local/bin/docker-entrypoint.sh | ||
|
||
ENTRYPOINT ["docker-entrypoint.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,60 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
REPLICA_SET_NAME=${REPLICA_SET_NAME:=rs0} | ||
USERNAME=${USERNAME:=dev} | ||
PASSWORD=${PASSWORD:=dev} | ||
|
||
|
||
function waitForMongo { | ||
port=$1 | ||
n=0 | ||
until [ $n -ge 20 ] | ||
do | ||
mongo admin --quiet --port $port --eval "db" && break | ||
n=$[$n+1] | ||
sleep 2 | ||
done | ||
} | ||
|
||
if [ ! "$(ls -A /data/db1)" ]; then | ||
mkdir /data/db1 | ||
mkdir /data/db2 | ||
mkdir /data/db3 | ||
fi | ||
|
||
echo "STARTING CLUSTER" | ||
|
||
mongod --port 27003 --dbpath /data/db3 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & | ||
DB3_PID=$! | ||
mongod --port 27002 --dbpath /data/db2 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & | ||
DB2_PID=$! | ||
mongod --port 27001 --dbpath /data/db1 --replSet $REPLICA_SET_NAME --bind_ip=::,0.0.0.0 & | ||
DB1_PID=$! | ||
|
||
waitForMongo 27001 | ||
waitForMongo 27002 | ||
waitForMongo 27003 | ||
|
||
echo "CONFIGURING REPLICA SET" | ||
CONFIG="{ _id: '$REPLICA_SET_NAME', members: [{_id: 0, host: 'localhost:27001', priority: 2 }, { _id: 1, host: 'localhost:27002' }, { _id: 2, host: 'localhost:27003' } ]}" | ||
mongo admin --port 27001 --eval "db.runCommand({ replSetInitiate: $CONFIG })" | ||
|
||
waitForMongo 27002 | ||
waitForMongo 27003 | ||
|
||
mongo admin --port 27001 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" | ||
mongo admin --port 27002 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" | ||
mongo admin --port 27003 --eval "db.runCommand({ setParameter: 1, quiet: 1 })" | ||
|
||
mongo admin --port 27001 --eval "db.adminCommand({ setParameter: 1, maxTransactionLockRequestTimeoutMillis: 5000 })" | ||
mongo admin --port 27002 --eval "db.adminCommand({ setParameter: 1, maxTransactionLockRequestTimeoutMillis: 5000 })" | ||
mongo admin --port 27003 --eval "db.adminCommand({ setParameter: 1, maxTransactionLockRequestTimeoutMillis: 5000 })" | ||
|
||
echo "REPLICA SET ONLINE" | ||
|
||
trap 'echo "KILLING"; kill $DB1_PID $DB2_PID $DB3_PID; wait $DB1_PID; wait $DB2_PID; wait $DB3_PID' SIGINT SIGTERM EXIT | ||
|
||
wait $DB1_PID | ||
wait $DB2_PID | ||
wait $DB3_PID |
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,3 @@ | ||
docker build -t mongodb-rs:latest ./.github/ | ||
|
||
docker run -d -p 27001:27001 -p 27002:27002 -p 27003:27003 --name mongo -e "REPLICA_SET_NAME=rs0" mongodb-rs |
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 @@ | ||
# Always validate the PR title AND all the commits | ||
titleAndCommits: true |
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,86 @@ | ||
name: main | ||
on: [push, pull_request] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [^16, ^18] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup MongoDB | ||
run: bash ./.github/mongo_setup.sh | ||
|
||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Dependency | ||
run: npm install --ignore-engines | ||
|
||
# - name: Build library | ||
# run: npm run build | ||
|
||
- name: Run unit tests | ||
run: npm run test | ||
|
||
coverall: | ||
needs: [test] | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [ ^16, ^18 ] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup MongoDB | ||
run: bash ./.github/mongo_setup.sh | ||
|
||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Dependency | ||
run: npm install --ignore-engines | ||
|
||
# - name: Build library | ||
# run: npm run build | ||
|
||
- name: Run code coverage | ||
run: npm run coverage | ||
|
||
- name: Coveralls Parallel | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
release: | ||
needs: [test,coverall] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Coveralls Finished | ||
uses: coverallsapp/github-action@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
parallel-finished: true | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Install Dependency | ||
run: npm install --ignore-engines | ||
|
||
# - name: Build library | ||
# run: npm run build | ||
|
||
- name: Release | ||
if: github.event_name == 'push' && github.repository == 'sefriol/resourcejs' && github.branch == 'master' | ||
run: npx -p semantic-release -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/commit-analyzer -p @semantic-release/release-notes-generator -p @semantic-release/release-notes-generator -p @semantic-release/changelog -p @semantic-release/git -p @semantic-release/github semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
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,21 @@ | ||
name: release-package | ||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
publish-gpr: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18 | ||
registry-url: https://npm.pkg.github.com/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} |
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
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 @@ | ||
{ | ||
"debug": true, | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/changelog", | ||
{ | ||
"changelogFile": "Changelog.md" | ||
} | ||
], | ||
[ | ||
"@semantic-release/git", | ||
{ | ||
"assets": ["package.json", "Changelog.md"], | ||
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" | ||
} | ||
], | ||
"@semantic-release/github" | ||
] | ||
} |
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
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
Oops, something went wrong.