2021-01-06 15:36:07 -05:00
|
|
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
2021-01-05 17:02:12 -05:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
|
2022-10-02 14:10:32 -04:00
|
|
|
name: Backend / Lint and Test
|
2021-01-05 17:02:12 -05:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ develop ]
|
|
|
|
pull_request:
|
|
|
|
branches: [ develop ]
|
|
|
|
|
2022-12-04 16:14:59 -05:00
|
|
|
concurrency:
|
2022-12-05 12:40:59 -05:00
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.job }}
|
2022-12-04 16:14:59 -05:00
|
|
|
cancel-in-progress: true
|
|
|
|
|
2022-03-06 15:05:40 -05:00
|
|
|
env:
|
2022-04-26 08:31:58 -04:00
|
|
|
NODEJS_VERSION: 18
|
2022-03-06 15:05:40 -05:00
|
|
|
|
2022-10-02 14:10:32 -04:00
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: backend
|
|
|
|
|
2021-01-05 17:02:12 -05:00
|
|
|
jobs:
|
2022-11-11 06:00:45 -05:00
|
|
|
changes:
|
|
|
|
name: Check for backend changes
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
outputs:
|
2022-11-21 11:24:36 -05:00
|
|
|
changed: ${{ github.event_name == 'push' || steps.changed.outputs.files }}
|
2022-11-11 06:00:45 -05:00
|
|
|
steps:
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
|
|
|
|
2022-11-11 06:00:45 -05:00
|
|
|
- name: Check for backend file changes
|
2022-11-21 11:24:36 -05:00
|
|
|
if: github.event_name != 'push'
|
2023-01-08 17:11:23 -05:00
|
|
|
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
|
2022-11-11 06:00:45 -05:00
|
|
|
id: changed
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
files:
|
2022-12-04 16:41:39 -05:00
|
|
|
- 'commons/**'
|
2022-11-11 06:00:45 -05:00
|
|
|
- 'backend/**'
|
|
|
|
- '.github/**'
|
|
|
|
- '.yarn/**'
|
|
|
|
|
2021-01-05 17:02:12 -05:00
|
|
|
lint:
|
2022-11-11 06:00:45 -05:00
|
|
|
needs: changes
|
2021-01-05 17:02:12 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2022-11-29 11:36:57 -05:00
|
|
|
- name: Setup node
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-11-29 11:36:57 -05:00
|
|
|
uses: ./.github/actions/setup-node
|
2021-01-05 17:02:12 -05:00
|
|
|
with:
|
2022-11-29 11:36:57 -05:00
|
|
|
NODE_VERSION: ${{ env.NODEJS_VERSION }}
|
2022-11-11 06:00:45 -05:00
|
|
|
|
2022-10-02 14:10:32 -04:00
|
|
|
- run: yarn run lint
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2021-01-05 17:02:12 -05:00
|
|
|
build:
|
2022-11-11 06:00:45 -05:00
|
|
|
needs: changes
|
2021-01-05 17:02:12 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-05 16:00:06 -04:00
|
|
|
node-version: [ 14.x, 16.x, 18.x ]
|
2021-01-05 17:02:12 -05:00
|
|
|
steps:
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2022-12-04 16:43:12 -05:00
|
|
|
- name: Setup node
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-12-04 16:43:12 -05:00
|
|
|
uses: ./.github/actions/setup-node
|
2021-01-05 17:02:12 -05:00
|
|
|
with:
|
2022-12-04 16:43:12 -05:00
|
|
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
2022-11-11 06:00:45 -05:00
|
|
|
|
2021-01-05 17:02:12 -05:00
|
|
|
- run: yarn run build
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2021-01-05 17:02:12 -05:00
|
|
|
|
|
|
|
integration-tests:
|
2022-11-11 06:00:45 -05:00
|
|
|
needs: changes
|
2021-01-05 17:02:12 -05:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2021-01-06 07:17:30 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2022-11-11 06:00:45 -05:00
|
|
|
|
2022-12-04 16:43:12 -05:00
|
|
|
- name: Setup node
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2022-12-04 16:43:12 -05:00
|
|
|
uses: ./.github/actions/setup-node
|
2021-01-05 17:02:12 -05:00
|
|
|
with:
|
2022-12-04 16:43:12 -05:00
|
|
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
2022-11-11 06:00:45 -05:00
|
|
|
|
2021-01-06 06:38:33 -05:00
|
|
|
- run: yarn run test:cov
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
|
|
|
|
2023-01-08 17:11:23 -05:00
|
|
|
- uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
|
2022-11-11 06:00:45 -05:00
|
|
|
if: needs.changes.outputs.changed == 'true'
|
2021-01-06 06:38:33 -05:00
|
|
|
with:
|
2022-10-02 14:10:32 -04:00
|
|
|
directory: backend/coverage
|
2021-01-06 06:38:33 -05:00
|
|
|
flags: integration-tests
|