Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI workflows from organization templates #633

Merged
merged 1 commit into from Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/doc-publish.yml

This file was deleted.

51 changes: 51 additions & 0 deletions .github/workflows/documentation.yml
@@ -0,0 +1,51 @@
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
65 changes: 65 additions & 0 deletions .github/workflows/node-test.yml
@@ -0,0 +1,65 @@
name: Node tests

on:
pull_request:
push:
branches:
- 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

steps:
- 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

- name: Test
run: npm run test --if-present

- name: Test and process coverage
run: npm run test:coverage --if-present
skjnldsv marked this conversation as resolved.
Show resolved Hide resolved

- 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
run: if ${{ needs.test.result != 'success' && needs.test.result != 'skipped' }}; then exit 1; fi
64 changes: 64 additions & 0 deletions .github/workflows/npm-publish.yml
@@ -0,0 +1,64 @@
# 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

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 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 }}
51 changes: 0 additions & 51 deletions .github/workflows/publish.yml

This file was deleted.

57 changes: 0 additions & 57 deletions .github/workflows/tests.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -2,6 +2,8 @@

[![Build Status](https://img.shields.io/github/actions/workflow/status/nextcloud/nextcloud-axios/tests.yml?branch=master)](https://github.com/nextcloud/nextcloud-axios/actions/workflows/tests.yml?query=branch%3Amaster)
[![npm](https://img.shields.io/npm/v/@nextcloud/axios.svg)](https://www.npmjs.com/package/@nextcloud/axios)
[![code coverage](https://img.shields.io/codecov/c/github/nextcloud/nextcloud-axios)](https://app.codecov.io/gh/nextcloud/nextcloud-axios)


Simple, typed wrapper of an Axios instance for Nextcloud that automatically sends authentication headers. [Cancellation](https://github.com/axios/axios#cancellation) is supported as well.

Expand Down
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -16,9 +16,12 @@
],
"scripts": {
"build": "rollup --config rollup.config.mjs",
"check-types": "tsc",
"dev": "rollup --config rollup.config.mjs --watch",
"test": "jest --setupFiles '<rootDir>/test/setup.js'",
"lint": "eslint lib test",
"lint:fix": "eslint --fix lib test",
"test": "jest --setupFiles '<rootDir>/test/setup.js' && npm run test:types",
"test:coverage": "jest --setupFiles '<rootDir>/test/setup.js' --coverage",
"test:types": "tsc --noEmit",
"test:watch": "jest --setupFiles '<rootDir>/test/setup.js' --watchAll"
},
"repository": {
Expand Down