misc: add turbo monorepo util

Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
Co-authored-by: David Mehren <git@herrmehren.de>
Co-authored-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: Erik Michelson <github@erik.michelson.eu>
Signed-off-by: David Mehren <git@herrmehren.de>
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Erik Michelson 2022-12-12 00:46:30 +01:00 committed by Tilman Vatteroth
parent e3512d3a87
commit 305b6f5910
41 changed files with 785 additions and 1218 deletions

View file

@ -9,3 +9,31 @@
!.yarn/plugins !.yarn/plugins
!.yarn/sdks !.yarn/sdks
!.yarn/versions !.yarn/versions
.pnp.*
**/node_modules
node_modules
frontend/.next
**/dist
.github
**/Dockerfile
.dockerignore
frontend/cypress/downloads
**/.env
backend/public/uploads
backend/uploads
backend/test_uploads
**/coverage
**/coverage-e2e
**/.nyc_output
backend/hedgedoc.sqlite
**/.turbo

View file

@ -6,9 +6,9 @@ name: Setup Node
description: "Setups node and configures the cache" description: "Setups node and configures the cache"
inputs: inputs:
NODE_VERSION: NODEJS_VERSION:
required: true required: true
type: string description: "NodeJS version to install"
runs: runs:
using: "composite" using: "composite"
@ -23,21 +23,16 @@ runs:
id: yarn-cache id: yarn-cache
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-${{ inputs.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }} key: ${{ runner.os }}-${{ inputs.NODEJS_VERSION }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-yarn-${{ inputs.NODE_VERSION }} ${{ runner.os }}-yarn-${{ inputs.NODEJS_VERSION }}
- name: Set up NodeJS - name: Set up NodeJS
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with: with:
node-version: ${{ inputs.NODE_VERSION }} node-version: ${{ inputs.NODEJS_VERSION }}
- name: Install dependencies - name: Install dependencies
run: yarn install --immutable run: yarn install --immutable
working-directory: . working-directory: .
shell: bash shell: bash
- name: Build commons lib
run: yarn build
working-directory: commons
shell: bash

View file

@ -1,24 +0,0 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Delete old container images
on:
schedule:
- cron: '0 0 * * *' # every day at midnight
workflow_dispatch:
jobs:
clean-ghcr:
name: Cleanup CI containers
runs-on: ubuntu-latest
steps:
- name: Cleanup CI containers
uses: snok/container-retention-policy@6601a342b42bf08909bbd5b48736d4176100365b # v1.5.1
with:
image-names: hedgedoc-ci
cut-off: A day ago UTC
account-type: org
org-name: ${{ github.repository_owner }}
token: ${{ secrets.PAT_IMAGE_CLEANUP }}

View file

@ -1,143 +0,0 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Backend / Docker
on:
push:
branches: [ develop ]
pull_request_target:
branches: [ develop ]
pull_request:
branches: [ develop ]
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ !!github.event.pull_request && github.event.pull_request.head.label || github.ref }}-${{ github.event_name }}-${{ github.job }}
cancel-in-progress: true
jobs:
changes:
name: Check for backend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for backend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'backend/**'
- '.github/**'
- '.yarn/**'
build-dev:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@15c905b16b06416d2086efa066dd8e3a35cc7f98 # v2.4.0
if: needs.changes.outputs.changed == 'true'
- name: Login to GHCR
if: needs.changes.outputs.changed == 'true'
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build dev image
if: needs.changes.outputs.changed == 'true'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: true
file: backend/docker/Dockerfile
tags: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
target: development
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
sqlite-test:
runs-on: ubuntu-latest
if: needs.changes.outputs.changed == 'true' && (github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork
needs: [ build-dev, changes ]
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
steps:
- run: cd /usr/src/app/backend && yarn run test
sqlite-e2e:
runs-on: ubuntu-latest
if: needs.changes.outputs.changed == 'true' && (github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork
needs: [ build-dev, changes ]
container:
image: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-ci:${{ github.sha }}
steps:
- run: cd /usr/src/app/backend && yarn run test:e2e
build-prod:
runs-on: ubuntu-latest
if: (github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork
needs: [ sqlite-test, sqlite-e2e, changes ]
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
- name: Generate Docker metadata
if: needs.changes.outputs.changed == 'true'
id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
if: needs.changes.outputs.changed == 'true'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@15c905b16b06416d2086efa066dd8e3a35cc7f98 # v2.4.0
if: needs.changes.outputs.changed == 'true'
- name: Login to GHCR
if: github.event_name == 'push' && needs.changes.outputs.changed == 'true'
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: needs.changes.outputs.changed == 'true'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: ${{ github.event_name == 'push' }}
file: backend/docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .

View file

@ -1,130 +0,0 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Backend / E2E Tests
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
env:
NODEJS_VERSION: 18
defaults:
run:
working-directory: backend
jobs:
changes:
name: Check for backend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for backend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'backend/**'
- '.github/**'
- '.yarn/**'
sqlite: # This run also collects coverage
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
with:
fetch-depth: 0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODEJS_VERSION }}
- run: yarn run test:e2e:cov
if: needs.changes.outputs.changed == 'true'
- uses: codecov/codecov-action@v3
if: needs.changes.outputs.changed == 'true'
with:
directory: backend/coverage-e2e
flags: e2e-tests
mariadb:
needs: changes
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb
env:
MYSQL_USER: hedgedoc
MYSQL_PASSWORD: hedgedoc
MYSQL_DATABASE: hedgedoc
MYSQL_ROOT_PASSWORD: hedgedoc
options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
ports:
- 3306:3306
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
with:
fetch-depth: 0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODEJS_VERSION }}
- run: yarn run test:e2e
if: needs.changes.outputs.changed == 'true'
env:
HEDGEDOC_TEST_DB_TYPE: mariadb
postgres:
needs: changes
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: hedgedoc
POSTGRES_USER: hedgedoc
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
with:
fetch-depth: 0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODEJS_VERSION }}
- run: yarn run test:e2e
if: needs.changes.outputs.changed == 'true'
env:
HEDGEDOC_TEST_DB_TYPE: postgres

View file

@ -1,106 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Backend / Lint and Test
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
env:
NODEJS_VERSION: 18
defaults:
run:
working-directory: backend
jobs:
changes:
name: Check for backend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for backend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'backend/**'
- '.github/**'
- '.yarn/**'
lint:
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODEJS_VERSION }}
- run: yarn run lint
if: needs.changes.outputs.changed == 'true'
build:
needs: changes
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 14.x, 16.x, 18.x ]
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODE_VERSION }}
- run: yarn run build
if: needs.changes.outputs.changed == 'true'
integration-tests:
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
with:
fetch-depth: 0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODE_VERSION }}
- run: yarn run test:cov
if: needs.changes.outputs.changed == 'true'
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
if: needs.changes.outputs.changed == 'true'
with:
directory: backend/coverage
flags: integration-tests

View file

@ -1,92 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ develop ]
paths:
- 'backend/src/'
- 'backend/test/'
- 'frontend/src/'
- 'frontend/cypress/'
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
paths:
- 'backend/src/'
- 'backend/test/'
- 'frontend/src/'
- 'frontend/cypress/'
schedule:
- cron: '15 4 * * 3'
permissions:
contents: read
security-events: write
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
category: "/language:${{ matrix.language }}"

View file

@ -1,60 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Commons / Lint
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
env:
NODE_VERSION: 18
defaults:
run:
working-directory: commons
jobs:
changes:
name: Check for commons changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- '.github/**'
- '.yarn/**'
lint:
needs: changes
runs-on: ubuntu-latest
name: Lints all .ts and .tsx files
steps:
- name: Checkout repository
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODE_VERSION }}
- name: Lint code
if: needs.changes.outputs.changed == 'true'
run: yarn lint

View file

@ -1,68 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Commons / Run unit tests & build
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
defaults:
run:
working-directory: commons
jobs:
changes:
name: Check for commons changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- '.github/**'
- '.yarn/**'
build:
needs: changes
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14', '16', '18' ]
name: Test and build with NodeJS ${{ matrix.node }}
steps:
- name: Checkout repository
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ matrix.node }}
- name: Test Project
if: needs.changes.outputs.changed == 'true'
run: yarn test
- name: Build project
if: needs.changes.outputs.changed == 'true'
run: yarn build

89
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,89 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Docker
on:
push:
branches: [ develop ]
permissions:
contents: read
packages: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Generate Docker metadata for backend
id: meta-backend
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/backend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Generate Docker metadata for frontend
id: meta-frontend
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/frontend
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@15c905b16b06416d2086efa066dd8e3a35cc7f98 # v2.4.0
- name: Login to GHCR
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push backend
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: true
file: backend/docker/Dockerfile
tags: ${{ steps.meta-backend.outputs.tags }}
labels: ${{ steps.meta-backend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
build-args:
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
TURBO_API: "${{ vars.TURBO_API }}"
TURBO_TEAM: "${{ vars.TURBO_TEAM }}"
- name: Build and push frontend
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: true
file: frontend/docker/Dockerfile
tags: ${{ steps.meta-frontend.outputs.tags }}
labels: ${{ steps.meta-frontend.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
build-args:
BUILD_VERSION: "${{ github.event.head_commit.id }}"
TURBO_TOKEN: "${{ secrets.TURBO_TOKEN }}"
TURBO_API: "${{ vars.TURBO_API }}"
TURBO_TEAM: "${{ vars.TURBO_TEAM }}"

193
.github/workflows/e2e-tests.yml vendored Normal file
View file

@ -0,0 +1,193 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: E2E Tests
on:
push:
branches: [ develop ]
pull_request_target:
branches: [ develop ]
pull_request:
branches: [ develop ]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ !!github.event.pull_request && github.event.pull_request.head.label || github.ref }}-${{ github.event_name }}-${{ github.job }}
cancel-in-progress: true
env:
NODEJS_VERSION: 18
HEAD_COMMIT_HASH: "${{ !!github.event.pull_request && github.event.pull_request.head.sha || github.sha }}"
jobs:
backend-sqlite: # This run also collects coverage
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn turbo run test:e2e:ci --filter=backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: sqlite
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Upload coverage
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
directory: backend/coverage-e2e
flags: e2e-tests
backend-mariadb:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
services:
mariadb:
image: mariadb
env:
MYSQL_USER: hedgedoc
MYSQL_PASSWORD: hedgedoc
MYSQL_DATABASE: hedgedoc
MYSQL_ROOT_PASSWORD: hedgedoc
options: --health-cmd "mysqladmin ping" --health-interval 5s --health-timeout 2s --health-retries 5
ports:
- 3306:3306
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn turbo run test:e2e:ci --filter=backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: mariadb
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
backend-postgres:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: hedgedoc
POSTGRES_USER: hedgedoc
options: --health-cmd pg_isready --health-interval 5s --health-timeout 2s --health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
fetch-depth: 0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run e2e tests
run: yarn turbo run test:e2e:ci --filter=backend
shell: bash
env:
HEDGEDOC_TEST_DB_TYPE: postgres
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
frontend-build:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
name: Build test build of frontend
steps:
- name: Check out repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ env.HEAD_COMMIT_HASH }}
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Build test production build
run: yarn turbo run build:test --filter=frontend
shell: bash
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
frontend-cypress:
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
needs: frontend-build
runs-on: ubuntu-latest
container:
image: cypress/browsers:node18.12.0-chrome106-ff106
options: --shm-size=2g
strategy:
fail-fast: false
matrix:
containers: [ 1, 2, 3 ]
steps:
- name: Check out repo
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Install jq
run: apt-get update && apt-get install -y jq
- name: Build test production build
run: yarn turbo run build:test --filter=frontend
shell: bash
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Run server
working-directory: frontend/
run: yarn start:ci &
env:
NODE_ENV: test
- name: Wait for server
run: "sleep 3 && curl --max-time 120 http://127.0.0.1:3001/"
- name: Run cypress
run: yarn turbo run test:e2e:ci --filter=frontend
shell: bash
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
CYPRESS_CONTAINER_ID: ${{ matrix.containers }}
- uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05 # master
with:
name: screenshots
path: cypress/screenshots

View file

@ -1,94 +0,0 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Frontend / build docker image
on:
push:
branches: [ develop ]
defaults:
run:
working-directory: frontend
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
changes:
name: Check for frontend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'frontend/**'
- '.github/**'
- '.yarn/**'
build:
needs: changes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: needs.changes.outputs.changed == 'true'
- name: Generate Docker metadata
if: needs.changes.outputs.changed == 'true'
id: meta
uses: docker/metadata-action@507c2f2dc502c992ad446e3d7a5dfbe311567a96 # v4.3.0
with:
images: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
if: needs.changes.outputs.changed == 'true'
uses: docker/setup-qemu-action@e81a89b1732b9c48d79cd809d8d81d79c4647a18 # v2.1.0
- name: Set up Docker Buildx
if: needs.changes.outputs.changed == 'true'
uses: docker/setup-buildx-action@15c905b16b06416d2086efa066dd8e3a35cc7f98 # v2.4.0
- name: Login to GHCR
if: github.event_name != 'pull_request' && needs.changes.outputs.changed == 'true'
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
if: needs.changes.outputs.changed == 'true'
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
with:
push: true
file: frontend/docker/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: .
build-args: |
BUILD_VERSION=${{ github.event.head_commit.id }}

View file

@ -1,174 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Frontend / Run E2E Tests
on:
push:
branches: [ develop ]
pull_request_target:
branches: [ develop ]
pull_request:
branches: [ develop ]
permissions:
contents: read
env:
NODE_VERSION: 18
HEAD_COMMIT_HASH: "${{ !!github.event.pull_request && github.event.pull_request.head.sha || github.sha }}"
defaults:
run:
working-directory: frontend
concurrency:
group: ${{ github.workflow }}-${{ !!github.event.pull_request && github.event.pull_request.head.label || github.ref }}-${{ github.event_name }}-${{ github.job }}
cancel-in-progress: true
jobs:
changes:
name: Check for frontend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'frontend/**'
- '.github/**'
- '.yarn/**'
build-frontend:
needs: changes
if: "(github.event_name == 'pull_request_target') == github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
name: Build test build of frontend
steps:
- name: Check out repo
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
with:
ref: ${{ env.HEAD_COMMIT_HASH }}
- name: Cache build
if: needs.changes.outputs.changed == 'true'
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
id: build-cache
with:
path: frontend/.next
key: ${{ env.HEAD_COMMIT_HASH }}
- name: Setup node
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODE_VERSION }}
- name: Build test production build
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
run: yarn build:test
- uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05 # master
if: needs.changes.outputs.changed == 'true'
with:
retention-days: 1
name: e2e-build
path: |
frontend/.next
!frontend/.next/cache
!frontend/.next/standalone
end2end:
name: Perform E2E Test in ${{ matrix.browser }}
needs:
- build-frontend
- changes
runs-on: ubuntu-latest
container:
image: cypress/browsers:node18.12.0-chrome106-ff106
options: --user 1001 --shm-size=2g
strategy:
fail-fast: false
matrix:
browser: [ 'chrome' ]
containers: [ 1, 2, 3, 4, 5 ]
steps:
- name: Check out repo
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Cache build
if: needs.changes.outputs.changed == 'true'
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
id: build-cache
with:
path: frontend/.next
key: ${{ env.HEAD_COMMIT_HASH }}
- name: Get yarn cache directory path
if: needs.changes.outputs.changed == 'true'
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache yarn cache
if: needs.changes.outputs.changed == 'true'
uses: actions/cache@627f0f41f6904a5b1efbaed9f96d9eb58e92e920 # v3.2.4
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
- name: Set up NodeJS
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
if: needs.changes.outputs.changed == 'true'
run: yarn install --immutable
- name: Download built frontend
if: needs.changes.outputs.changed == 'true'
uses: actions/download-artifact@e9ef242655d12993efdcda9058dee2db83a2cb9b # master
with:
name: e2e-build
path: frontend/.next
- name: Run server
if: needs.changes.outputs.changed == 'true'
run: yarn start:ci &
env:
NODE_ENV: test
- name: Wait for server
if: needs.changes.outputs.changed == 'true'
run: "sleep 3 && curl --max-time 120 http://127.0.0.1:3001/"
- name: Run cypress
if: needs.changes.outputs.changed == 'true'
run: "yarn cy:run:${{ matrix.browser }} --record true --parallel --group \"UI - ${{ matrix.browser }}\""
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@65d862660abb392b8c4a3d1195a2108db131dd05 # master
if: needs.changes.outputs.changed == 'true'
with:
name: screenshots
path: cypress/screenshots

View file

@ -1,61 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Frontend / Lint
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
env:
NODE_VERSION: 18
defaults:
run:
working-directory: frontend
jobs:
changes:
name: Check for frontend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'frontend/**'
- '.github/**'
- '.yarn/**'
lint:
needs: changes
runs-on: ubuntu-latest
name: Lints all .ts and .tsx files
steps:
- name: Checkout repository
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ env.NODE_VERSION }}
- name: Lint code
if: needs.changes.outputs.changed == 'true'
run: yarn lint

View file

@ -10,7 +10,7 @@ on:
env: env:
NETLIFY_VERSION: 12.0.11 NETLIFY_VERSION: 12.0.11
NODE_VERSION: 18 NODEJS_VERSION: 18
defaults: defaults:
run: run:
@ -21,74 +21,47 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
changes:
name: Check for frontend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'frontend/**'
- '.github/**'
- '.yarn/**'
deploy: deploy:
needs: changes
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Deploys to netlify name: Deploys to netlify
steps: steps:
- name: Checkout repository - name: Checkout repository
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node - name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node uses: ./.github/actions/setup-node
with: with:
NODE_VERSION: ${{ env.NODE_VERSION }} NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Patch intro.md to include netlify banner. - name: Patch intro.md to include netlify banner.
if: needs.changes.outputs.changed == 'true'
run: cp netlify/intro.md public/public/intro.md run: cp netlify/intro.md public/public/intro.md
- name: Patch motd.md to include privacy policy. - name: Patch motd.md to include privacy policy.
if: needs.changes.outputs.changed == 'true'
run: cp netlify/motd.md public/public/motd.md run: cp netlify/motd.md public/public/motd.md
- name: Patch version.json to include git hash - name: Patch version.json to include git hash
if: needs.changes.outputs.changed == 'true'
run: jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json && mv src/_version.json src/version.json run: jq ".version = \"0.0.0+${GITHUB_SHA:0:8}\"" src/version.json > src/_version.json && mv src/_version.json src/version.json
- name: Patch base URL - name: Patch base URL
if: needs.changes.outputs.changed == 'true'
run: echo "HD_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production run: echo "HD_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production
- name: Build app - name: Build app
if: needs.changes.outputs.changed == 'true' run: yarn turbo run build --filter=frontend
run: yarn build:mock shell: bash
working-directory: .
env:
NEXT_PUBLIC_USE_MOCK_API: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Remove Next.js cache to avoid it being deployed - name: Remove Next.js cache to avoid it being deployed
if: needs.changes.outputs.changed == 'true'
run: rm -r .next/cache run: rm -r .next/cache
- name: Install netlify CLI - name: Install netlify CLI
if: needs.changes.outputs.changed == 'true'
run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}" run: "npm install -g netlify-cli@${{ env.NETLIFY_VERSION }}"
- name: Run netlify CLI deployment - name: Run netlify CLI deployment
if: needs.changes.outputs.changed == 'true'
env: env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\"" run: "netlify deploy --build --prod --message \"${{ github.event.head_commit.id }}: ${{ github.event.head_commit.message }}\""

View file

@ -28,7 +28,7 @@ permissions:
env: env:
NETLIFY_VERSION: 12.0.11 NETLIFY_VERSION: 12.0.11
NODE_VERSION: 18 NODEJS_VERSION: 18
defaults: defaults:
run: run:
@ -59,8 +59,8 @@ jobs:
files: files:
- 'commons/**' - 'commons/**'
- 'frontend/**' - 'frontend/**'
- '.github/**' - 'yarn.lock'
- '.yarn/**' - 'package.json'
deploy: deploy:
needs: changes needs: changes
@ -80,7 +80,7 @@ jobs:
if: needs.changes.outputs.changed == 'true' if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node uses: ./.github/actions/setup-node
with: with:
NODE_VERSION: ${{ env.NODE_VERSION }} NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Patch intro.md to include netlify banner. - name: Patch intro.md to include netlify banner.
if: needs.changes.outputs.changed == 'true' if: needs.changes.outputs.changed == 'true'
@ -100,7 +100,14 @@ jobs:
- name: Build app - name: Build app
if: needs.changes.outputs.changed == 'true' if: needs.changes.outputs.changed == 'true'
run: yarn build:mock run: yarn turbo run build --filter=frontend
shell: bash
working-directory: .
env:
NEXT_PUBLIC_USE_MOCK_API: true
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Remove Next.js cache to avoid it being deployed - name: Remove Next.js cache to avoid it being deployed
if: needs.changes.outputs.changed == 'true' if: needs.changes.outputs.changed == 'true'

View file

@ -1,69 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Frontend / Run unit tests & build
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
defaults:
run:
working-directory: frontend
jobs:
changes:
name: Check for frontend changes
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
steps:
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
if: github.event_name != 'push'
- name: Check for frontend file changes
if: github.event_name != 'push'
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
id: changed
with:
filters: |
files:
- 'commons/**'
- 'frontend/**'
- '.github/**'
- '.yarn/**'
build:
needs: changes
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14', '16', '18' ]
name: Test and build with NodeJS ${{ matrix.node }}
steps:
- name: Checkout repository
if: needs.changes.outputs.changed == 'true'
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
if: needs.changes.outputs.changed == 'true'
uses: ./.github/actions/setup-node
with:
NODE_VERSION: ${{ matrix.node }}
- name: Test Project
if: needs.changes.outputs.changed == 'true'
run: yarn test:ci
- name: Build project
if: needs.changes.outputs.changed == 'true'
run: yarn build:mock

36
.github/workflows/lint.yml vendored Normal file
View file

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Lint and check format
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
env:
NODEJS_VERSION: 18
jobs:
lint:
runs-on: ubuntu-latest
name: Lint files and check formatting
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ env.NODEJS_VERSION }}
- name: Run ESLint
run: yarn turbo run lint
shell: bash
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}

View file

@ -1,31 +0,0 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: "Njsscan Analysis"
on:
push:
branches: [ develop ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ develop ]
schedule:
- cron: '0 7 * * 6'
jobs:
njsscan:
runs-on: ubuntu-latest
name: Njsscan code scanning
steps:
- name: Checkout the code
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Scan with njsscan
id: njsscan
uses: ajinabraham/njsscan-action@d58d8b2f26322cd35a9efb8003baac517f226d81 # master
with:
args: '--sarif --output results.sarif src || true'
- name: Upload njsscan report
uses: github/codeql-action/upload-sarif@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
sarif_file: results.sarif

63
.github/workflows/static-analysis.yml vendored Normal file
View file

@ -0,0 +1,63 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Static Analysis
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
schedule:
- cron: '0 7 * * 6'
permissions:
actions: read
contents: read
security-events: write
jobs:
njsscan:
runs-on: ubuntu-latest
name: Njsscan code scanning
steps:
- name: Checkout the code
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Scan with njsscan
id: njsscan
uses: ajinabraham/njsscan-action@d58d8b2f26322cd35a9efb8003baac517f226d81 # master
with:
args: '--sarif --output results.sarif src || true'
- name: Upload njsscan report
uses: github/codeql-action/upload-sarif@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
sarif_file: results.sarif
codeql:
name: CodeQL analysis
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Initialize CodeQL
uses: github/codeql-action/init@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@3ebbd71c74ef574dbc558c82f70e52732c8b44fe # v2.2.1
with:
category: "/language:${{ matrix.language }}"

59
.github/workflows/test-and-build.yml vendored Normal file
View file

@ -0,0 +1,59 @@
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: AGPL-3.0-only
name: Run tests & build
on:
push:
branches: [ develop ]
pull_request:
branches: [ develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '14', '16', '18' ]
include:
- node: '18'
coverage: true
name: Test and build with NodeJS ${{ matrix.node }}
steps:
- name: Checkout repository
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
- name: Setup node
uses: ./.github/actions/setup-node
with:
NODEJS_VERSION: ${{ matrix.node }}
- name: Build project
run: yarn turbo run build
shell: bash
env:
NODEJS_VERSION: ${{ matrix.node }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Test Project
run: yarn turbo run test:ci
shell: bash
env:
NODEJS_VERSION: ${{ matrix.node }}
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_API: ${{ vars.TURBO_API }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
- name: Upload coverage
if: "${{ matrix.coverage == true }}"
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
directory: backend/coverage
flags: integration-tests

2
.gitignore vendored
View file

@ -20,6 +20,8 @@ backups/
*.pid *.pid
*.log *.log
*.sqlite *.sqlite
.turbo
# Yarn 2 without zero-installs # Yarn 2 without zero-installs
.yarn/* .yarn/*

View file

@ -91,6 +91,10 @@ Files: .yarnrc.yml
Copyright: 2021 The HedgeDoc developers (see AUTHORS file) Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0 License: CC0-1.0
Files: .turbo/config.json
Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0
Files: frontend/.gitattributes Files: frontend/.gitattributes
Copyright: 2021 The HedgeDoc developers (see AUTHORS file) Copyright: 2021 The HedgeDoc developers (see AUTHORS file)
License: CC0-1.0 License: CC0-1.0

View file

@ -1,6 +0,0 @@
# SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
#
# SPDX-License-Identifier: CC0-1.0
dist
.pnp.*

View file

@ -14,58 +14,35 @@ FROM docker.io/node:19-alpine@sha256:72b0f918ad76b5ef68c6243869fab5800d7393c1dcc
# Add tini to handle signals # Add tini to handle signals
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals # https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals
RUN apk add --no-cache tini RUN apk add --no-cache tini
ENTRYPOINT ["tini"] ENTRYPOINT ["tini", "--"]
ENV YARN_CACHE_FOLDER /tmp/.yarn ENV YARN_CACHE_FOLDER /tmp/.yarn
USER node
WORKDIR /usr/src/app
## Stage 1: Code with all dependencies ## Stage 1: Code with all dependencies
FROM base as code-with-deps FROM base as code-with-deps
RUN apk add --no-cache libc6-compat
USER node USER node
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY --chown=node .yarn/plugins .yarn/plugins COPY --chown=node . .
COPY --chown=node .yarn/patches .yarn/patches
COPY --chown=node .yarn/releases .yarn/releases
COPY --chown=node .yarnrc.yml .yarnrc.yml
COPY --chown=node package.json package.json
COPY --chown=node yarn.lock yarn.lock
COPY --chown=node backend/package.json backend/
COPY --chown=node commons/package.json commons/
COPY --chown=node frontend/package.json frontend/
# Install dependencies first to not invalidate the cache on every source change # Install dependencies first to not invalidate the cache on every source change
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \ RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn install --immutable && yarn workspaces focus @hedgedoc/backend yarn install --immutable && yarn workspaces focus hedgedoc @hedgedoc/backend @hedgedoc/commons
COPY --chown=node commons/ commons/ ## Stage 2a: Compile TypeScript
COPY --chown=node backend/nest-cli.json backend/tsconfig.json backend/tsconfig.build.json backend/ FROM code-with-deps as builder
COPY --chown=node backend/src backend/src
WORKDIR /usr/src/app/commons
RUN yarn build
## Stage 2a: Dev config files and tests
FROM code-with-deps as development
USER node USER node
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY --chown=node eslint-local-rules.js eslint-local-rules.js ARG TURBO_TEAM
COPY --chown=node backend/.eslintrc.js backend/.prettierrc.json backend/jest-e2e.json backend/ ARG TURBO_API
COPY --chown=node backend/test backend/test ARG TURBO_TOKEN
CMD ["node", "-r", "ts-node/register", "src/main.ts"] RUN yarn turbo run build --filter=backend --no-cache --no-daemon
## Stage 2b: Compile TypeScript ## Stage 2b: Install only prod dependencies
FROM code-with-deps as builder
USER node
WORKDIR /usr/src/app/backend
RUN yarn run build
## Stage 3a: Install only prod dependencies
FROM code-with-deps as prod-dependencies FROM code-with-deps as prod-dependencies
USER node USER node
WORKDIR /usr/src/app WORKDIR /usr/src/app
@ -73,7 +50,7 @@ WORKDIR /usr/src/app
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \ RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn workspaces focus --production @hedgedoc/backend yarn workspaces focus --production @hedgedoc/backend
## Stage 3a: Final image, only production dependencies ## Stage 3: Final image, only production dependencies
FROM base as prod FROM base as prod
LABEL org.opencontainers.image.title='HedgeDoc production image' LABEL org.opencontainers.image.title='HedgeDoc production image'
@ -94,7 +71,7 @@ COPY --chown=node --from=builder /usr/src/app/backend/dist backend/dist
COPY --chown=node backend/public backend/public COPY --chown=node backend/public backend/public
COPY --chown=node commons/package.json /usr/src/app/commons/package.json COPY --chown=node commons/package.json /usr/src/app/commons/package.json
COPY --chown=node --from=prod-dependencies /usr/src/app/commons/dist commons/dist COPY --chown=node --from=builder /usr/src/app/commons/dist commons/dist
WORKDIR /usr/src/app/backend WORKDIR /usr/src/app/backend
CMD ["node", "dist/main.js"] CMD ["node", "dist/main.js"]

View file

@ -17,10 +17,10 @@
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:cov": "jest --coverage", "test:ci": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config jest-e2e.json && rimraf test_uploads*", "test:e2e": "jest --config jest-e2e.json && rimraf test_uploads*",
"test:e2e:cov": "jest --config jest-e2e.json --coverage && rimraf test_uploads*", "test:e2e:ci": "jest --config jest-e2e.json --coverage && rimraf test_uploads*",
"seed": "ts-node src/seed.ts" "seed": "ts-node src/seed.ts"
}, },
"dependencies": { "dependencies": {

View file

@ -9,6 +9,7 @@
"build": "rm -rf dist && microbundle", "build": "rm -rf dist && microbundle",
"build:watch": "rm -rf dist && microbundle -w", "build:watch": "rm -rf dist && microbundle -w",
"test": "jest", "test": "jest",
"test:ci": "jest --ci",
"prepublish": "rm -rf dist && yarn lint && yarn build && yarn test", "prepublish": "rm -rf dist && yarn lint && yarn build && yarn test",
"lint": "eslint src --ext .ts", "lint": "eslint src --ext .ts",
"lint:fix": "eslint --fix --ext .ts src" "lint:fix": "eslint --fix --ext .ts src"

View file

@ -8,6 +8,8 @@
log { log {
output stdout output stdout
level WARN
format console
} }
reverse_proxy /realtime http://127.0.0.1:3000 reverse_proxy /realtime http://127.0.0.1:3000

View file

@ -0,0 +1,9 @@
{
"name": "@hedgedoc/dev-reverse-proxy",
"version": "0.0.0",
"private": true,
"license": "AGPL-3.0",
"scripts": {
"start:dev": "./caddy run"
}
}

View file

@ -14,32 +14,31 @@ To run HedgeDoc 2.0 you need three components: the backend, the frontend and the
Backend and Frontend are included in the [HegdeDoc repo](https://github.com/hedgedoc/hedgedoc). The reverse proxy can be chosen by preference. For development, we Backend and Frontend are included in the [HegdeDoc repo](https://github.com/hedgedoc/hedgedoc). The reverse proxy can be chosen by preference. For development, we
recommend caddy and the provided configuration. recommend caddy and the provided configuration.
1. Install Node.js (at least Node 14, we recommend Node 18) and [Yarn](https://yarnpkg.com/getting-started/install) 1. Clone [our repository](https://github.com/hedgedoc/hedgedoc.git) and go into its directory
2. Install Caddy (select one of the two options) ```shell
git clone https://github.com/hedgedoc/hedgedoc.git
cd hedgedoc
```
2. Install Node.js (at least Node 14, we recommend Node 18) and [Yarn](https://yarnpkg.com/getting-started/install)
3. Install Caddy (select one of the two options)
- [Download](https://caddyserver.com/) and place the `caddy` binary in `hedgedoc/dev-reverse-proxy`. Ensure it is executable with `chmod +x caddy`. Users of macOS may need to run `xattr -d com.apple.quarantine ./caddy` to lift the quarantine for executables from the internet. - [Download](https://caddyserver.com/) and place the `caddy` binary in `hedgedoc/dev-reverse-proxy`. Ensure it is executable with `chmod +x caddy`. Users of macOS may need to run `xattr -d com.apple.quarantine ./caddy` to lift the quarantine for executables from the internet.
- Install Caddy using your package manager - Install Caddy using your package manager
3. Clone [our repository](https://github.com/hedgedoc/hedgedoc.git) and go into its directory
```shell
git clone https://github.com/hedgedoc/hedgedoc.git
cd hedgedoc
```
4. Install the dependencies in repo root directory with `yarn install` 4. Install the dependencies in repo root directory with `yarn install`
5. Go to `hedgedoc/commons` directory with `cd ../commons` 5. Goto `hedgedoc/backend` directory with `cd backend`
6. Build the commons package with `yarn build` 6. Create the `.env` config file by copying the example: `cp .env.example .env`
7. Goto `hedgedoc/backend` directory with `cd ../backend` 7. Add a value to `HD_SESSION_SECRET` in the .env file. This can be any string, which has to be a secure password for production but can be set to simple string for debug purpose.
8. Create the `.env` config file by copying the example: `cp .env.example .env` 8. Execute the following lines
9. Add a value to `HD_SESSION_SECRET` in the .env file. This can be any string, which has to be a secure password for production but can be set to simple string for debug purpose. ```shell
10. Execute the following lines echo "HD_AUTH_LOCAL_ENABLE_LOGIN=true" >> .env
```shell echo "HD_AUTH_LOCAL_ENABLE_REGISTER=true" >> .env
echo "HD_AUTH_LOCAL_ENABLE_LOGIN=true" >> .env ```
echo "HD_AUTH_LOCAL_ENABLE_REGISTER=true" >> .env 9. Go back into the root directory with `cd ..`
``` 10. Run `yarn start:dev`
11. Start the backend using `yarn start:dev` > This will execute the backend, frontend and reverse proxy at once
12. Go to `hedgedoc/frontend` directory with `cd ../frontend` 11. Use your browser to go to <http://localhost:8080>
13. Start the frontend using `yarn run dev:with-local-backend`
14. Go to `hedgedoc/dev-reverse-proxy` with `cd ../dev-reverse-proxy` ## More detailed development setup
15. Start Caddy using `./caddy run` (if you've downloaded the binary manually) or `caddy run` (if you've installed Caddy using a package manager) The following sections describe a more detailed setup of all components.
16. Use your browser to go to <http://localhost:8080>
## Preconditions ## Preconditions
@ -87,18 +86,19 @@ This only needs to be done once, except if you've changed code in the commons pa
The frontend can be run in four different ways. The development mode compiles everything on demand. So the first time The frontend can be run in four different ways. The development mode compiles everything on demand. So the first time
you open a page in the browser it may take some time. you open a page in the browser it may take some time.
See [here](setup/frontend.md) for a more detailed description of the environment variables for the frontend. See [here](setup/frontend.md) for a more detailed description of the environment variables for the frontend.
A special configuration isn't necessary but keep in mind that you execute all commands from within the `frontend` directory.
### Mocked backend ### Mocked backend
To start the development mode, run `yarn run dev`. To start the development mode, run `yarn start:dev:mock` .
By default, this will run in mock-mode, meaning instead of running a real backend the frontend mocks the backend. This task will run the frontend in mock-mode, meaning instead of running a real backend, the frontend mocks the backend.
This way you can work on frontend functionality without starting up the full development environment. This way you can work on frontend functionality without starting up the full development environment.
The app should run now and be available under [http://localhost:3001](http://localhost:3001) in your browser. The app should run now and be available under [http://localhost:3001](http://localhost:3001) in your browser.
In development mode the app will autoload changes you make to the code. In development mode the app will autoload changes you make to the code.
### With local backend ### With local backend
To start the development mode with an actual HedgeDoc backend use `yarn run dev:with-local-backend` instead. To start the development mode with an actual HedgeDoc backend use `yarn start:dev` instead.
This task will automatically set `HD_BASE_URL` to `http://localhost:8080`. This task will automatically set `HD_BASE_URL` to `http://localhost:8080`.
### Production mode ### Production mode

View file

@ -39,7 +39,7 @@ Unit testing is done via jest.
We use [cypress](https://cypress.io) for e2e tests. We use [cypress](https://cypress.io) for e2e tests.
1. Start the frontend with `yarn dev:test` (or use a test build using `yarn build:test` which you can start 1. Start the frontend with `yarn start:dev:test` (or use a test build using `yarn build:test` which you can start
using `yarn start`). The usage of `:test` is mandatory! using `yarn start`). The usage of `:test` is mandatory!
2. Run `yarn cy:open` to open the cypress test loader 2. Run `yarn cy:open` to open the cypress test loader
3. Choose your browser and start a test suite 3. Choose your browser and start a test suite

View file

@ -1,7 +0,0 @@
Dockerfile
.dockerignore
node_modules
npm-debug.log
README.md
.next
.git

View file

@ -1,3 +1,2 @@
NEXT_PUBLIC_USE_MOCK_API=true HD_BASE_URL="http://localhost:8080/"
HD_BASE_URL="http://localhost:3001/" HD_RENDERER_BASE_URL="http://127.0.0.1:8080/"
HD_RENDERER_BASE_URL="http://127.0.0.1:3001/"

View file

@ -2,8 +2,15 @@
# #
# SPDX-License-Identifier: CC-BY-SA-4.0 # SPDX-License-Identifier: CC-BY-SA-4.0
# BASE
FROM docker.io/node:18-alpine@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3 AS base
RUN apk add --no-cache tini
ENTRYPOINT ["tini", "--"]
# BUILD # BUILD
FROM docker.io/node:18-alpine@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3 AS builder FROM base AS builder
RUN apk add --no-cache libc6-compat
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1
ARG BUILD_VERSION=CLIENT_VERSION_MISSING ARG BUILD_VERSION=CLIENT_VERSION_MISSING
@ -12,31 +19,21 @@ ENV YARN_CACHE_FOLDER /tmp/.yarn
USER node USER node
WORKDIR /usr/src/app WORKDIR /usr/src/app
COPY --chown=node .yarn/plugins .yarn/plugins COPY --chown=node . .
COPY --chown=node .yarn/patches .yarn/patches
COPY --chown=node .yarn/releases .yarn/releases
COPY --chown=node .yarnrc.yml .yarnrc.yml
COPY --chown=node package.json package.json
COPY --chown=node yarn.lock yarn.lock
COPY --chown=node backend/package.json backend/
COPY --chown=node commons commons
COPY --chown=node frontend frontend
RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \ RUN --mount=type=cache,sharing=locked,uid=1000,gid=1000,target=/tmp/.yarn \
yarn install --immutable && yarn workspaces focus @hedgedoc/frontend yarn install --immutable && yarn workspaces focus hedgedoc @hedgedoc/backend @hedgedoc/commons
WORKDIR /usr/src/app/commons ARG TURBO_TEAM
ARG TURBO_API
ARG TURBO_TOKEN
RUN yarn build RUN rm -rf frontend/public/public
RUN rm -rf frontend/src/pages/api
WORKDIR /usr/src/app/frontend RUN sed -i "s/CLIENT_VERSION_MISSING/${BUILD_VERSION}/" frontend/src/version.json
RUN yarn turbo run build --filter=frontend --no-cache --no-daemon
RUN rm -rf public/public && \
rm -rf src/pages/api && \
sed -i "s/CLIENT_VERSION_MISSING/${BUILD_VERSION}/" src/version.json
RUN yarn build
# RUNNER # RUNNER
FROM docker.io/node:18-alpine@sha256:bc329c7332cffc30c2d4801e38df03cbfa8dcbae2a7a52a449db104794f168a3 FROM base
ENV NODE_ENV=production ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1 ENV NEXT_TELEMETRY_DISABLED=1

View file

@ -8,20 +8,21 @@
"build:mock": "cross-env NEXT_PUBLIC_USE_MOCK_API=true next build", "build:mock": "cross-env NEXT_PUBLIC_USE_MOCK_API=true next build",
"build:test": "cross-env NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true next build", "build:test": "cross-env NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true next build",
"analyze": "cross-env ANALYZE=true yarn build", "analyze": "cross-env ANALYZE=true yarn build",
"dev": "cross-env PORT=3001 next dev",
"dev:test": "cross-env PORT=3001 NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true next dev",
"dev:with-local-backend": "cross-env PORT=3001 NEXT_PUBLIC_USE_MOCK_API=false HD_BASE_URL=http://localhost:8080/ HD_RENDERER_BASE_URL=http://localhost:8080/ next dev",
"format": "prettier -c \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"", "format": "prettier -c \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"",
"format:fix": "prettier -w \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"", "format:fix": "prettier -w \"src/**/*.{ts,tsx,js}\" \"cypress/**/*.{ts,tsx}\"",
"lint": "eslint --max-warnings=0 --ext .ts,.tsx src", "lint": "eslint --max-warnings=0 --ext .ts,.tsx src",
"lint:fix": "eslint --fix --ext .ts,.tsx src", "lint:fix": "eslint --fix --ext .ts,.tsx src",
"start": "cross-env PORT=3001 next start", "start": "cross-env PORT=3001 next start",
"start:ci": "cross-env NODE_ENV=test PORT=3001 next start", "start:ci": "cross-env PORT=3001 NODE_ENV=test next start",
"cy:open": "cypress open", "start:dev": "cross-env PORT=3001 next dev",
"cy:run:chrome": "cypress run --browser chrome", "start:dev:mock": "cross-env PORT=3001 NEXT_PUBLIC_USE_MOCK_API=true HD_BASE_URL=\"http://localhost:3001/\" HD_RENDERER_BASE_URL=\"http://127.0.0.1:3001/\" next dev",
"cy:run:firefox": "cypress run --browser firefox", "start:dev:test": "cross-env PORT=3001 NODE_ENV=test NEXT_PUBLIC_TEST_MODE=true next dev",
"test": "cross-env NODE_ENV=test jest --watch", "test:e2e:open": "cypress open",
"test:ci": "cross-env NODE_ENV=test jest --ci" "test:e2e": "cypress run --browser chrome",
"test:e2e:ci": "cypress run --browser chrome --record true --parallel --group \"chrome\"",
"test:watch": "cross-env NODE_ENV=test jest --watch",
"test:ci": "cross-env NODE_ENV=test jest --ci",
"test": "cross-env NODE_ENV=test jest"
}, },
"browserslist": { "browserslist": {
"production": [ "production": [

View file

@ -5,8 +5,15 @@
"workspaces": [ "workspaces": [
"backend", "backend",
"frontend", "frontend",
"commons" "commons",
"dev-reverse-proxy"
], ],
"scripts": {
"build": "turbo run build",
"lint": "turbo run lint",
"format": "turbo run format",
"start:dev": "turbo run start:dev"
},
"packageManager": "yarn@3.4.1", "packageManager": "yarn@3.4.1",
"resolutions": { "resolutions": {
"domhandler": "5.0.3", "domhandler": "5.0.3",
@ -22,5 +29,8 @@
"@types/react": "18.0.27", "@types/react": "18.0.27",
"y-protocols@^1.0.0": "patch:y-protocols@npm%3A1.0.5#./.yarn/patches/y-protocols-npm-1.0.5-af6f64b4df.patch", "y-protocols@^1.0.0": "patch:y-protocols@npm%3A1.0.5#./.yarn/patches/y-protocols-npm-1.0.5-af6f64b4df.patch",
"y-protocols@1.0.5": "patch:y-protocols@npm%3A1.0.5#./.yarn/patches/y-protocols-npm-1.0.5-af6f64b4df.patch" "y-protocols@1.0.5": "patch:y-protocols@npm%3A1.0.5#./.yarn/patches/y-protocols-npm-1.0.5-af6f64b4df.patch"
},
"devDependencies": {
"turbo": "1.6.3"
} }
} }

View file

@ -95,7 +95,7 @@
".github/workflows/deploy-pr.yml$" ".github/workflows/deploy-pr.yml$"
], ],
"matchStrings": [ "matchStrings": [
"NODE_VERSION=(?<currentValue>.*?)\\n" "NODEJS_VERSION=(?<currentValue>.*?)\\n"
], ],
"datasourceTemplate": "node", "datasourceTemplate": "node",
"depNameTemplate": "node version in workflows" "depNameTemplate": "node version in workflows"

108
turbo.json Normal file
View file

@ -0,0 +1,108 @@
{
"$schema": "https://turbo.build/schema.json",
"pipeline": {
"build": {},
"@hedgedoc/commons#build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
]
},
"@hedgedoc/frontend#build": {
"dependsOn": [
"^build"
],
"outputs": [
".next/**"
],
"env": [
"NODEJS_VERSION"
]
},
"@hedgedoc/backend#build": {
"dependsOn": [
"^build"
],
"outputs": [
"dist/**"
],
"env": [
"NODEJS_VERSION"
]
},
"build:test": {},
"@hedgedoc/frontend#build:test": {
"dependsOn": [
"^build"
],
"outputs": [
".next/**"
],
"env": [
"NODEJS_VERSION"
]
},
"lint": {
"dependsOn": [
"^build"
]
},
"format": {},
"test:ci": {},
"@hedgedoc/backend#test:ci": {
"dependsOn": [
"^build"
],
"env": [
"NODEJS_VERSION"
],
"outputs": [
"coverage/**"
]
},
"@hedgedoc/frontend#test:ci": {
"dependsOn": [
"^build"
],
"env": [
"NODEJS_VERSION"
]
},
"test:e2e:ci": {},
"@hedgedoc/frontend#test:e2e:ci": {
"dependsOn": [
"^build"
],
"env": [
"CYPRESS_CONTAINER_ID"
]
},
"@hedgedoc/backend#test:e2e:ci": {
"dependsOn": [
"^build"
],
"env": [
"HEDGEDOC_TEST_DB_TYPE"
],
"outputs": [
"coverage-e2e/**"
]
},
"start:dev": {
"dependsOn": [
"^build"
],
"cache": false,
"persistent": true
}
}
}

View file

@ -2310,6 +2310,12 @@ __metadata:
languageName: unknown languageName: unknown
linkType: soft linkType: soft
"@hedgedoc/dev-reverse-proxy@workspace:dev-reverse-proxy":
version: 0.0.0-use.local
resolution: "@hedgedoc/dev-reverse-proxy@workspace:dev-reverse-proxy"
languageName: unknown
linkType: soft
"@hedgedoc/frontend@workspace:frontend": "@hedgedoc/frontend@workspace:frontend":
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "@hedgedoc/frontend@workspace:frontend" resolution: "@hedgedoc/frontend@workspace:frontend"
@ -10429,6 +10435,8 @@ __metadata:
"hedgedoc@workspace:.": "hedgedoc@workspace:.":
version: 0.0.0-use.local version: 0.0.0-use.local
resolution: "hedgedoc@workspace:." resolution: "hedgedoc@workspace:."
dependencies:
turbo: 1.6.3
languageName: unknown languageName: unknown
linkType: soft linkType: soft
@ -17334,6 +17342,77 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"turbo-darwin-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-darwin-64@npm:1.6.3"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"turbo-darwin-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-darwin-arm64@npm:1.6.3"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"turbo-linux-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-linux-64@npm:1.6.3"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
"turbo-linux-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-linux-arm64@npm:1.6.3"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
"turbo-windows-64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-windows-64@npm:1.6.3"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"turbo-windows-arm64@npm:1.6.3":
version: 1.6.3
resolution: "turbo-windows-arm64@npm:1.6.3"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"turbo@npm:1.6.3":
version: 1.6.3
resolution: "turbo@npm:1.6.3"
dependencies:
turbo-darwin-64: 1.6.3
turbo-darwin-arm64: 1.6.3
turbo-linux-64: 1.6.3
turbo-linux-arm64: 1.6.3
turbo-windows-64: 1.6.3
turbo-windows-arm64: 1.6.3
dependenciesMeta:
turbo-darwin-64:
optional: true
turbo-darwin-arm64:
optional: true
turbo-linux-64:
optional: true
turbo-linux-arm64:
optional: true
turbo-windows-64:
optional: true
turbo-windows-arm64:
optional: true
bin:
turbo: bin/turbo
checksum: 35195f4b7623014c25ba152c11a8cb23e51cbd75dc9266d0656692665f85b28faf3496dea8cecacf52795a917410668124186ffbdcf276325ccc3e11df9e9623
languageName: node
linkType: hard
"tweetnacl@npm:^0.14.3, tweetnacl@npm:~0.14.0": "tweetnacl@npm:^0.14.3, tweetnacl@npm:~0.14.0":
version: 0.14.5 version: 0.14.5
resolution: "tweetnacl@npm:0.14.5" resolution: "tweetnacl@npm:0.14.5"