From 350df36187e88d44da35fb29ee53c08f4c624bd8 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 11 Jul 2023 14:29:21 +0200 Subject: [PATCH] chore(ci): Use and update github workflows from organization Signed-off-by: Ferdinand Thiessen --- .github/workflows/doc-publish.yml | 46 -------------------- .github/workflows/documentation.yml | 56 ++++++++++++++++++++++++ .github/workflows/node-test.yml | 66 ++++++++++++++++++++++------- .github/workflows/npm-publish.yml | 65 ++++++++++++++++++++++++++++ .github/workflows/publish.yml | 51 ---------------------- 5 files changed, 171 insertions(+), 113 deletions(-) delete mode 100644 .github/workflows/doc-publish.yml create mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/npm-publish.yml delete mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml deleted file mode 100644 index 93956489..00000000 --- a/.github/workflows/doc-publish.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Doc Publish - -on: - release: - types: [published] - -jobs: - publish: - runs-on: ubuntu-latest - - name: Publish doc - steps: - - name: Check actor permission level - uses: skjnldsv/check-actor-permission@v2 - with: - require: admin - - - name: Checkout - uses: actions/checkout@v3 - - - name: Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.2 - id: versions - with: - fallbackNode: '^16' - fallbackNpm: '^8' - - - name: Set up node ${{ steps.versions.outputs.nodeVersion }} - uses: actions/setup-node@v3 - with: - node-version: ${{ steps.versions.outputs.nodeVersion }} - - - name: Set up npm ${{ steps.versions.outputs.npmVersion }} - run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" - - - name: Install dependencies & build - run: | - npm ci - npm run build - npm run build:doc - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./dist/doc diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 00000000..4bb25dbf --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,56 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Documentation + +on: + pull_request: + release: + types: [published] + +jobs: + build-and-deploy: + runs-on: ubuntu-latest + + name: Build and deploy + steps: + - name: Check actor permission level + # Only allow admin to deploy on release + if: github.event.release + uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2 + with: + require: admin + + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + id: versions + with: + fallbackNode: '^20' + fallbackNpm: '^9' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies & build + run: | + npm ci + npm run build --if-present + npm run build:doc --if-present + + - name: Deploy + # Only deploy on release + if: github.event.release + uses: peaceiris/actions-gh-pages@373f7f263a76c20808c831209c920827a82a2847 # v3.9.3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist/doc diff --git a/.github/workflows/node-test.yml b/.github/workflows/node-test.yml index e1b76863..52b5cb47 100644 --- a/.github/workflows/node-test.yml +++ b/.github/workflows/node-test.yml @@ -1,35 +1,69 @@ -name: Node +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Node tests on: pull_request: push: branches: - - 'master' + - main + - master + - stable* + +permissions: + contents: read + +concurrency: + group: node-tests-${{ github.head_ref || github.run_id }} + cancel-in-progress: true jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - node: [20] - name: Test Node v${{ matrix.node }} + steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + id: versions + with: + fallbackNode: '^20' + fallbackNpm: '^9' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3.7.0 with: - node-version: ${{ matrix.node }} - cache: 'npm' - - name: install dependencies - run: npm ci - - name: build package - run: npm run build - - name: run tests - run: npm run test + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies & build + run: | + npm ci + npm run build --if-present + + - name: Test + run: npm run test --if-present + + - name: Test and process coverage + run: npm run test:coverage --if-present + + - name: Collect coverage + uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 + with: + files: ./coverage/lcov.info summary: runs-on: ubuntu-latest needs: test if: always() + name: test-summary steps: - name: Summary status diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 00000000..7246549e --- /dev/null +++ b/.github/workflows/npm-publish.yml @@ -0,0 +1,65 @@ +# This workflow is provided via the organization template repository +# +# https://github.com/nextcloud/.github +# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization + +name: Publish + +on: + release: + types: [published] + +permissions: + contents: read + packages: write + +jobs: + publish: + runs-on: ubuntu-latest + + name: Build and publish to npm + steps: + - name: Check actor permission level + uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2.1 + with: + require: admin + + - name: Checkout + uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + + - name: Read package.json node and npm engines version + uses: skjnldsv/read-package-engines-version-actions@8205673bab74a63eb9b8093402fd9e0e018663a1 # v2.2 + id: versions + with: + fallbackNode: '^20' + fallbackNpm: '^9' + + - name: Set up node ${{ steps.versions.outputs.nodeVersion }} + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3 + with: + node-version: ${{ steps.versions.outputs.nodeVersion }} + + - name: Set up npm ${{ steps.versions.outputs.npmVersion }} + run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}" + + - name: Install dependencies & build + run: | + npm ci + npm run build --if-present + + - name: Publish + run: | + npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN + npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Setup Github Package Registry + uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3 + with: + registry-url: 'https://npm.pkg.github.com' + + - name: Publish package on GPR + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2e0d20d9..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish - -on: - release: - types: [published] - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - name: ๐Ÿ”’โ€‹ Check actor permission level - uses: skjnldsv/check-actor-permission@v2 - with: - require: admin - - - name: ๐Ÿ“ฅโ€‹ Checkout - uses: actions/checkout@v3 - - - name: ๐Ÿช„ Read package.json node and npm engines version - uses: skjnldsv/read-package-engines-version-actions@v1.2 - id: versions - with: - fallbackNode: '^16' - fallbackNpm: '^8' - - - name: ๐Ÿ”งโ€‹ Setup Node (NPM Registry) - uses: actions/setup-node@v3 - with: - node-version: ${{ steps.versions.outputs.nodeVersion }} - cache: 'npm' - registry-url: 'https://registry.npmjs.org' - - - name: ๐Ÿ“ฆ Install dependencies & build - run: | - npm ci - npm run build - - - name: ๐Ÿ“ฃ Publish package on NPM - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - - name: ๐Ÿ”งโ€‹ Setup Github Registry - uses: actions/setup-node@v3 - with: - registry-url: 'https://npm.pkg.github.com' - - - name: ๐Ÿ“ฃ Publish package on GPR - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}