Skip to content

Instantly share code, notes, and snippets.

@amkisko
Last active October 15, 2023 08:35
Show Gist options
  • Save amkisko/cf91b7f1f085dbfdb7df9f9be2f64ffc to your computer and use it in GitHub Desktop.
Save amkisko/cf91b7f1f085dbfdb7df9f9be2f64ffc to your computer and use it in GitHub Desktop.
GitHub Actions + Node.js MongoDB Minio linting and testing
# FILEPATH: .github/workflows/workflow.yml
# AUTHOR: Andrei Makarov (github.com/amkisko)
name: Workflow
on: [push]
jobs:
test:
runs-on: ubuntu-latest
env:
S3_BUCKET: testbucket
S3_API_KEY: testkey
S3_API_SECRET: testsecret
S3_ENDPOINT: http://0.0.0.0:9000
services:
mongo:
image: mongo
ports: ['27017:27017']
minio:
image: bitnami/minio
ports: ['9000:9000']
env:
MINIO_ACCESS_KEY: testkey
MINIO_SECRET_KEY: testsecret
MINIO_DEFAULT_BUCKETS: testbucket
steps:
- name: 'Checkout repository'
uses: actions/checkout@v1
- name: Run linters
uses: samuelmeuli/lint-action@v1
with:
github_token: ${{ secrets.github_token }}
eslint: true
prettier: true
- name: 'Install Ruby version specified in `.ruby-version`'
uses: eregon/use-ruby-action@master
- name: 'Read Node.js version'
run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
id: nvm
- name: 'Install Node.js'
uses: actions/setup-node@v1
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- name: 'Setup caching for npm cache'
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
- name: 'npm install'
run: npm install
- name: 'Install Foreman'
run: gem install foreman
- name: 'Install wait-on'
run: npm install -g wait-on
- name: 'Test'
env:
MONGODB_URI: mongodb://localhost
S3_IMAGES_DIR_SUFFIX: testsuffix
S3_URL: http://localhost:9000
run: |
foreman run node server.js >/dev/null &
wait-on -t 30000 http-get://localhost:5000
npm run test-and-empty-db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment