diff --git a/.github/workflows/doc-publish.yml b/.github/workflows/doc-publish.yml deleted file mode 100644 index b733089..0000000 --- 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@v2 - 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 0000000..f24bdea --- /dev/null +++ b/.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 diff --git a/.github/workflows/node-test.yml b/.github/workflows/node-test.yml new file mode 100644 index 0000000..52a519e --- /dev/null +++ b/.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 + + - 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 diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml new file mode 100644 index 0000000..622006d --- /dev/null +++ b/.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 }} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 2e0d20d..0000000 --- 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 }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 753b0d2..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Node - -on: - pull_request: - push: - branches: - - 'master' - -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 - 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 - - types: - runs-on: ubuntu-latest - strategy: - matrix: - node: [ 20 ] - name: Test Types on Node v${{ matrix.node }} - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node }} - cache: 'npm' - - name: install dependencies - run: npm ci - - name: check types - run: npm run check-types - - summary: - runs-on: ubuntu-latest - needs: - - test - - types - if: always() - name: test-summary - steps: - - name: Test summary status - run: if ${{ needs.test.result != 'success' && needs.test.result != 'skipped' }}; then exit 1; fi - - name: Types summary status - run: if ${{ needs.types.result != 'success' && needs.types.result != 'skipped' }}; then exit 1; fi diff --git a/README.md b/README.md index 2f68d93..e314e3c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index 3c8b902..a178912 100644 --- a/package.json +++ b/package.json @@ -16,9 +16,12 @@ ], "scripts": { "build": "rollup --config rollup.config.mjs", - "check-types": "tsc", "dev": "rollup --config rollup.config.mjs --watch", - "test": "jest --setupFiles '/test/setup.js'", + "lint": "eslint lib test", + "lint:fix": "eslint --fix lib test", + "test": "jest --setupFiles '/test/setup.js' && npm run test:types", + "test:coverage": "jest --setupFiles '/test/setup.js' --coverage", + "test:types": "tsc --noEmit", "test:watch": "jest --setupFiles '/test/setup.js' --watchAll" }, "repository": {