-
-
Notifications
You must be signed in to change notification settings - Fork 279
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
172 changed files
with
11,294 additions
and
22,102 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
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,85 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: [ master ] | ||
# Triggers the workflow on pull request events in the context of the fork | ||
# trying to sidestep limitations here: https://github.com/wearerequired/lint-action/issues/13 | ||
pull_request: | ||
|
||
jobs: | ||
build-test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
# Label used to access the service container | ||
postgres: | ||
# Docker Hub image | ||
image: postgres:12.3 | ||
# Provide the password for postgres | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: bookbrainz_test | ||
# Since we run npm tests on the host machine (not in a docker container) | ||
# we need to bind the Postgres port from Docker container to host machine | ||
ports: | ||
- 5432:5432 | ||
# Set health checks to wait until postgres has started | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
steps: | ||
|
||
- name: Install PostgreSQL client | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install --yes postgresql-client | ||
#Set up ElasticSearch | ||
- name: Run Elasticsearch | ||
# Replace this with official elastic-github-actions/elasticsearch once they are ready for prod | ||
uses: getong/elasticsearch-action@v1.2 | ||
with: | ||
elasticsearch version: '5.6.8' | ||
host port: 9200 | ||
container port: 9200 | ||
host node port: 9300 | ||
node port: 9300 | ||
discovery type: 'single-node' | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
# Set up the test dabatase | ||
- name: Set up test database in PostgreSQL | ||
run: ./scripts/create-test-db.sh | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_PASSWORD: postgres | ||
POSTGRES_DB: bookbrainz_test | ||
|
||
- name: Set up node | ||
uses: actions/setup-node@v1 | ||
with: | ||
# We could also test on multiple Node versions if needed: https://github.com/actions/setup-node#matrix-testing | ||
node-version: '12' | ||
# Enables caching NPM dependencies (uses https://github.com/actions/cache under the hood) | ||
cache: 'yarn' | ||
|
||
# Performs a clean installation of all dependencies in the `package.json` file | ||
# For more information, see https://docs.npmjs.com/cli/ci.html | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Run tests | ||
run: yarn run test-ci # run tests (configured to use mocha's json reporter) | ||
|
||
- name: Export test results | ||
uses: actions/upload-artifact@v2 # upload test results | ||
if: success() || failure() # run this step even if previous step failed | ||
with: | ||
name: test-results | ||
path: test-results.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
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 @@ | ||
# Run ESLint on pull requests (limited permissions) | ||
|
||
name: Lint pull requests | ||
|
||
# Controls when the action will run. | ||
on: | ||
# Triggers the workflow on pull request events in the context of the fork | ||
# trying to sidestep limitations here: https://github.com/wearerequired/lint-action/issues/13 | ||
pull_request_target: | ||
|
||
# Limit permissions of the token | ||
# When running an untrusted fork, we don't want to give write permissions | ||
# See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ | ||
permissions: | ||
checks: write # Allows the creation of annotations on forks | ||
contents: read # Don't allow untrusted forks write access | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run-linters-pull-request: | ||
name: Run linters for pull requests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
|
||
- name: NPM install | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Run linters | ||
uses: wearerequired/lint-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
eslint: true | ||
# Auto-fix requires write permissions to commit changes, which we don't want to allow | ||
# See https://github.com/wearerequired/lint-action/issues/13 | ||
auto_fix: false | ||
|
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,37 @@ | ||
# This workflow can be used to push an image off a branch to Docker Hub. | ||
# This is useful to deploy changes from any branch/PR to BookBrainz beta or test for testing. | ||
name: Push development Docker image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Docker Image Tag (Version)' | ||
required: true | ||
default: 'beta' | ||
|
||
jobs: | ||
|
||
dev: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Login to Docker Hub | ||
run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} --password-stdin | ||
continue-on-error: true | ||
|
||
- uses: satackey/action-docker-layer-caching@v0.0.11 | ||
continue-on-error: true | ||
|
||
- name: Build development image | ||
run: | | ||
docker build \ | ||
--target bookbrainz-prod \ | ||
--tag metabrainz/bookbrainz:"${{ github.event.inputs.tag }}" \ | ||
--build-arg DEPLOY_ENV="${{ github.event.inputs.tag }}" \ | ||
--build-arg GIT_COMMIT_SHA="${{ github.sha }}" . | ||
- name: Push development image | ||
run: docker push metabrainz/bookbrainz:"${{ github.event.inputs.tag }}" |
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,16 @@ | ||
name: Test Report | ||
on: | ||
workflow_run: | ||
workflows: ['CI'] # runs after CI workflow | ||
types: | ||
- completed | ||
jobs: | ||
report: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: dorny/test-reporter@v1 | ||
with: | ||
artifact: test-results # artifact name | ||
name: Mocha Tests # Name of the check run which will be created | ||
path: '*.json' # Path to test results (inside artifact .zip) | ||
reporter: mocha-json # Format of test results |
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 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
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.