mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-12 22:26:08 -04:00
feat(ci): deduplicate and fix node setup
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
2241a3faea
commit
534540855c
8 changed files with 60 additions and 146 deletions
38
.github/actions/setup-node/action.yml
vendored
Normal file
38
.github/actions/setup-node/action.yml
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
name: Setup Node
|
||||||
|
description: "Setups node and configures the cache"
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
NODE_VERSION:
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- name: Get yarn cache directory path
|
||||||
|
id: yarn-cache-dir-path
|
||||||
|
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Cache yarn cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
id: yarn-cache
|
||||||
|
with:
|
||||||
|
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-${{ inputs.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-yarn-${{ inputs.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Set up NodeJS
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: ${{ inputs.NODE_VERSION }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: yarn install --immutable
|
||||||
|
working-directory: .
|
||||||
|
shell: bash
|
16
.github/workflows/backend-e2e-tests.yml
vendored
16
.github/workflows/backend-e2e-tests.yml
vendored
|
@ -49,16 +49,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Use Node.js ${{ env.NODEJS_VERSION }}
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
NODE_VERSION: ${{ env.NODEJS_VERSION }}
|
||||||
node-version: ${{ env.NODEJS_VERSION }}
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
|
|
||||||
- run: yarn run test:e2e:cov
|
- run: yarn run test:e2e:cov
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
@ -93,9 +88,8 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
|
||||||
node-version: ${{ env.NODEJS_VERSION }}
|
node-version: ${{ env.NODEJS_VERSION }}
|
||||||
cache: 'yarn'
|
|
||||||
- run: yarn install --immutable
|
- run: yarn install --immutable
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
||||||
|
@ -126,9 +120,7 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
|
||||||
node-version: ${{ env.NODEJS_VERSION }}
|
node-version: ${{ env.NODEJS_VERSION }}
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
- run: yarn install --immutable
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
15
.github/workflows/backend-tests.yml
vendored
15
.github/workflows/backend-tests.yml
vendored
|
@ -48,16 +48,11 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
||||||
- name: Use Node.js ${{ env.NODEJS_VERSION }}
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
NODE_VERSION: ${{ env.NODEJS_VERSION }}
|
||||||
node-version: ${{ env.NODEJS_VERSION }}
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
|
|
||||||
- run: yarn run lint
|
- run: yarn run lint
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
@ -76,9 +71,7 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
- run: yarn install --immutable
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
@ -99,9 +92,7 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
cache-dependency-path: backend/yarn.lock
|
|
||||||
node-version: ${{ env.NODEJS_VERSION }}
|
node-version: ${{ env.NODEJS_VERSION }}
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- run: yarn install --immutable
|
- run: yarn install --immutable
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
29
.github/workflows/frontend-e2e-tests.yml
vendored
29
.github/workflows/frontend-e2e-tests.yml
vendored
|
@ -71,32 +71,11 @@ jobs:
|
||||||
path: frontend/.next
|
path: frontend/.next
|
||||||
key: ${{ env.HEAD_COMMIT_HASH }}
|
key: ${{ env.HEAD_COMMIT_HASH }}
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Setup node
|
||||||
id: yarn-cache-dir-path
|
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache yarn cache
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
||||||
|
uses: ./.github/actions/setup-node
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||||
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@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
|
||||||
run: yarn install --immutable
|
|
||||||
|
|
||||||
- name: Build test production build
|
- name: Build test production build
|
||||||
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
if: steps.build-cache.outputs.cache-hit != 'true' && needs.changes.outputs.changed == 'true'
|
||||||
|
@ -159,8 +138,6 @@ jobs:
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: ${{ env.NODE_VERSION }}
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
27
.github/workflows/frontend-lint.yml
vendored
27
.github/workflows/frontend-lint.yml
vendored
|
@ -49,32 +49,11 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache yarn cache
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||||
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
||||||
|
|
||||||
- name: Set up NodeJS
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
run: yarn install --immutable
|
|
||||||
|
|
||||||
- name: Lint code
|
- name: Lint code
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
|
@ -52,28 +52,11 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache yarn cache
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||||
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
||||||
|
|
||||||
- name: Set up NodeJS
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- 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'
|
||||||
|
@ -91,10 +74,6 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
run: echo "HD_EDITOR_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production
|
run: echo "HD_EDITOR_BASE_URL=\"https://hedgedoc.dev/\"" >> .env.production
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
run: yarn install --immutable
|
|
||||||
|
|
||||||
- name: Build app
|
- name: Build app
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
run: yarn build:mock
|
run: yarn build:mock
|
||||||
|
|
27
.github/workflows/frontend-netlify-deploy-pr.yml
vendored
27
.github/workflows/frontend-netlify-deploy-pr.yml
vendored
|
@ -75,28 +75,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.pull_request.head.sha }}
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache yarn cache
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
NODE_VERSION: ${{ env.NODE_VERSION }}
|
||||||
key: ${{ runner.os }}-${{ env.NODE_VERSION }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-${{ env.NODE_VERSION }}
|
|
||||||
|
|
||||||
- name: Set up NodeJS
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- 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'
|
||||||
|
@ -114,10 +97,6 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
run: echo "HD_EDITOR_BASE_URL=\"${{ env.DEPLOY_URL }}\"" >> .env.production
|
run: echo "HD_EDITOR_BASE_URL=\"${{ env.DEPLOY_URL }}\"" >> .env.production
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
run: yarn install --immutable
|
|
||||||
|
|
||||||
- name: Build app
|
- name: Build app
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
run: yarn build:mock
|
run: yarn build:mock
|
||||||
|
|
27
.github/workflows/frontend-test-and-build.yml
vendored
27
.github/workflows/frontend-test-and-build.yml
vendored
|
@ -49,32 +49,11 @@ jobs:
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Get yarn cache directory path
|
- name: Setup node
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
id: yarn-cache-dir-path
|
uses: ./.github/actions/setup-node
|
||||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Cache yarn cache
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/cache@v3
|
|
||||||
id: yarn-cache
|
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
NODE_VERSION: ${{ matrix.node }}
|
||||||
key: ${{ runner.os }}-${{ matrix.node }}-yarn-${{ hashFiles('frontend/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-yarn-${{ matrix.node }}
|
|
||||||
|
|
||||||
- name: Set up NodeJS
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
uses: actions/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: ${{ matrix.node }}
|
|
||||||
cache-dependency-path: frontend/yarn.lock
|
|
||||||
cache: 'yarn'
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: needs.changes.outputs.changed == 'true'
|
|
||||||
run: yarn install --immutable
|
|
||||||
|
|
||||||
- name: Test Project
|
- name: Test Project
|
||||||
if: needs.changes.outputs.changed == 'true'
|
if: needs.changes.outputs.changed == 'true'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue