Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDo committed Mar 3, 2022
2 parents a204158 + b110625 commit d81c056
Show file tree
Hide file tree
Showing 172 changed files with 11,294 additions and 22,102 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[
"babel-plugin-transform-require-ignore",
{
"extensions": [".less", ".css"]
"extensions": [".scss", ".css"]
}
]
],
Expand Down
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable import/unambiguous, import/no-commonjs, no-magic-numbers */
/* eslint-disable no-inline-comments */


const options = {
env: {
es6: true,
Expand Down
2 changes: 1 addition & 1 deletion .github/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
newPRWelcomeComment: |
Thanks for opening your first pull request for BookBrainz, and welcome to our community! :tada:
If you haven't yet, please check out our [contributing guidelines](https://github.com/bookbrainz/bookbrainz-site/blob/master/CONTRIBUTING.md).
If you haven't yet, please check out our [contributing guidelines](https://github.com/metabrainz/bookbrainz-site/blob/master/CONTRIBUTING.md).
Someone will be reviewing your PR soon; just hang in there !
In the meantime, if you're wondering what to do next, you can have a look at our [issue tracker](https://tickets.metabrainz.org/browse/BB)
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/ci.yml
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
3 changes: 0 additions & 3 deletions .github/workflows/jsdoc-gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# Also check out Lobes bootstrap theme submodule
submodules: true

- name: NPM install
uses: bahmutov/npm-install@v1
Expand Down
44 changes: 44 additions & 0 deletions .github/workflows/lint-pull-requests.yml
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

20 changes: 9 additions & 11 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Run ESLint with autofix
# Run ESLint with autofix on push to master branch

name: Lint
name: Lint and autofix issues

# Controls when the action will run.
# Controls when the action will run.
on:
# Triggers the workflow on push events for the master branch
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_target:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
run-linters:
Expand All @@ -19,14 +20,11 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
# Also check out Lobes bootstrap theme submodule
submodules: true

- name: NPM install
uses: bahmutov/npm-install@v1
uses: bahmutov/npm-install@v1

- name: Run linters
- name: Run linters and autofix issues
uses: wearerequired/lint-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/push-dev-docker-image.yml
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 }}"
16 changes: 16 additions & 0 deletions .github/workflows/test-report.yml
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ coverage
# nyc test coverage
.nyc_output

# mocha CI test coverage
test-results.json

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

20 changes: 0 additions & 20 deletions .snyk

This file was deleted.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ We welcome all contributors of all ranks to contribute towards Metabrainz founda
` git push origin BranchName`

#### Pull Request
After pushing your changes to the remote, you can create a pull request by going to the [repository](https://github.com/bookbrainz/bookbrainz-site) page on github.
After pushing your changes to the remote, you can create a pull request by going to the [repository](https://github.com/metabrainz/bookbrainz-site) page on github.


24 changes: 13 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ARG GIT_COMMIT_SHA

ARG BUILD_DEPS=" \
build-essential \
python-dev \
libpq5 \
libpq-dev"
python-dev"

ARG RUN_DEPS=" \
bzip2 \
git \
rsync \
libpq5 \
libpq-dev \
ca-certificates"


Expand All @@ -27,7 +27,7 @@ RUN apt-get update && \
# PostgreSQL client
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
ENV PG_MAJOR 12
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' $PG_MAJOR > /etc/apt/sources.list.d/pgdg.list
RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
RUN apt-get update \
&& apt-get install -y --no-install-recommends postgresql-client-$PG_MAJOR \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -46,9 +46,9 @@ RUN echo $GIT_COMMIT_SHA > .git-version

# Files necessary to complete the JavaScript build
COPY --chown=bookbrainz scripts/ scripts/
COPY --chown=bookbrainz .babelrc .eslintrc.js .eslintignore webpack.client.js package.json package-lock.json ./
COPY --chown=bookbrainz .babelrc .eslintrc.js .eslintignore webpack.client.js package.json yarn.lock ./

RUN npm install --no-audit
RUN yarn install

COPY --chown=bookbrainz static/ static/
COPY --chown=bookbrainz config/ config/
Expand All @@ -60,7 +60,7 @@ COPY --chown=bookbrainz src/ src/
FROM bookbrainz-base as bookbrainz-dev
ARG DEPLOY_ENV

CMD ["npm", "start"]
CMD ["yarn", "start"]

# Production target
FROM bookbrainz-base as bookbrainz-prod
Expand All @@ -87,8 +87,9 @@ ADD ./docker/crontab /etc/cron.d/bookbrainz
RUN chmod 0644 /etc/cron.d/bookbrainz && crontab -u bookbrainz /etc/cron.d/bookbrainz

# Build JS project and assets
RUN ["npm", "run", "build"]
RUN ["npm", "prune", "--production"]
RUN ["yarn", "run", "build"]
# Prune off the dev dependencies after build step
RUN ["yarn", "install", "--production", "--ignore-scripts", "--prefer-offline"]

# API target
FROM bookbrainz-base as bookbrainz-webservice
Expand All @@ -105,5 +106,6 @@ RUN chmod 755 /etc/service/webserver/run
RUN touch /etc/service/webserver/down

# Build API JS
RUN ["npm", "run", "build-api-js"]
RUN ["npm", "prune", "--production"]
RUN ["yarn", "run", "build-api-js"]
# Prune off the dev dependencies after build step
RUN ["yarn", "install", "--production", "--ignore-scripts", "--prefer-offline"]
Loading

0 comments on commit d81c056

Please sign in to comment.