diff --git a/.github/codeql/codeql-configuration.yml b/.github/codeql/config.yml similarity index 100% rename from .github/codeql/codeql-configuration.yml rename to .github/codeql/config.yml diff --git a/.github/scripts/config.js b/.github/scripts/config.js deleted file mode 100644 index 2e93fc85..00000000 --- a/.github/scripts/config.js +++ /dev/null @@ -1,28 +0,0 @@ -import semver from 'semver'; -import { promises as fs } from 'fs'; - -const packageData = await fs.readFile(new URL('../../package.json', import.meta.url)); -const { engines } = JSON.parse(packageData); - -const comparators = semver - .toComparators(engines.node) - .flat() - .map(v => semver.coerce(v)); -const minVersion = semver.minSatisfying(comparators, engines.node).version; -const maxVersion = semver.maxSatisfying(comparators, engines.node).version; -const mainVersion = `${semver.major(maxVersion)}.x`; - -console.log( - JSON.stringify({ - node: { - matrix: { - node: [minVersion, mainVersion], - os: ['ubuntu-latest'], - }, - main: { - version: mainVersion, - os: 'ubuntu-latest', - }, - }, - }) -); diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 52ff8521..10abcd2a 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,20 +1,24 @@ -name: Auto merge - -on: - pull_request: - branches: - - 'dev' +name: Dependabot auto-merge +on: pull_request permissions: - pull-requests: write contents: write + pull-requests: write jobs: - auto-merge: + dependabot: runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} steps: - - uses: actions/checkout@v2 - - uses: ahmadnassri/action-dependabot-auto-merge@v2 + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.1.1 with: - target: minor - github-token: ${{ secrets.AUTO_MERGE_TOKEN }} + github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 16521bb3..898032d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,49 +10,19 @@ on: - '*' jobs: - config: - name: Configure - runs-on: ubuntu-latest - outputs: - config: ${{ steps.set-config.outputs.config }} - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v2 - - - name: Create config - id: set-config - run: | - echo Node: $(node -v) - echo NPM: $(npm -v) - npm i semver - CONFIG=$(node ./.github/scripts/config.js | sed 's/ //g') - echo "::set-output name=config::$CONFIG" - echo $CONFIG - test: name: Test - needs: [ config ] - strategy: - matrix: ${{ fromJson(needs.config.outputs.config).node.matrix }} - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + env: + NODE_VERSION: 16 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Setup Node.js v${{ matrix.node }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node }} - - - name: Cache node modules - id: cache-npm - uses: actions/cache@v2 + - name: Setup Node.js v${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 with: - path: ~/.npm - key: npm-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }} + node-version: ${{ env.NODE_VERSION }} - name: Install Dependencies run: npm ci @@ -65,34 +35,26 @@ jobs: npm run test - name: Cache coverage - if: ${{ success() && matrix.node == '16.x' }} - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: coverage - key: coverage-${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }} + key: coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }} build: name: Build - needs: [ test, config ] + needs: [ test ] + runs-on: ubuntu-latest env: - NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }} - runs-on: ${{ fromJson(needs.config.outputs.config).node.main.os }} + NODE_VERSION: 16 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - - name: Cache node modules - id: cache-npm - uses: actions/cache@v2 - with: - path: ~/.npm - key: npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }} - - name: Install Dependencies run: npm ci env: @@ -104,35 +66,27 @@ jobs: coverage: name: Coverage if: ${{ github.event_name == 'push' }} - needs: [ build, config ] + needs: [ build ] + runs-on: ubuntu-latest env: - NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }} - runs-on: ${{ fromJson(needs.config.outputs.config).node.main.os }} + NODE_VERSION: 16 steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Cache coverage id: cache-coverage - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: coverage key: coverage-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('src/**/*.*', '**/package-lock.json') }} - name: Setup Node.js v${{ env.NODE_VERSION }} if: steps.cache-coverage.outputs.cache-hit != 'true' - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} - - name: Cache node modules - if: steps.cache-coverage.outputs.cache-hit != 'true' - id: cache-npm - uses: actions/cache@v2 - with: - path: ~/.npm - key: npm-${{ runner.os }}-${{ env.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }} - - name: Test if: steps.cache-coverage.outputs.cache-hit != 'true' run: | @@ -142,7 +96,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Send coverage report - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: ./coverage/lcov.info @@ -159,77 +113,10 @@ jobs: USER: admin:${{ secrets.GITHUB_TOKEN }} FILTER: "[.jobs[] | select(.status==\"completed\" and .conclusion==\"failure\") | { status: .conclusion, matrix: .name}] | length" run: | - failure_count=$(curl -X GET -s -u $USER $URL | jq "$FILTER") - echo "::set-output name=failure_count::$failure_count" - echo Failure jobs count: $failure_count + FAILURE_COUNT=$(curl -X GET -s -u $USER $URL | jq "$FILTER") + echo "fails=$FAILURE_COUNT" >> $GITHUB_OUTPUT + echo Failure jobs count: $FAILURE_COUNT - - if: ${{ steps.status.outputs.failure_count > 0 }} + - if: ${{ steps.status.outputs.fails > 0 }} name: Fail run: exit 1 - - discord: - name: Discord notification - needs: [ status ] - if: ${{ always() }} - runs-on: ubuntu-latest - env: - DISCORD_USERNAME: github - DISCORD_ERROR_COLOR: 16726645 - DISCORD_ERROR_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-error.png - DISCORD_EVENT_COLOR: 53759 - DISCORD_EVENT_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-event.png - steps: - - name: Send error notification after push commit - if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'push' }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - username: ${{ env.DISCORD_USERNAME }} - avatar_url: ${{ env.DISCORD_ERROR_AVATAR }} - title: 'Build failed :confused:' - color: ${{ env.DISCORD_ERROR_COLOR }} - description: | - **Repository:** `${{ github.repository }}` - **Branch:** `${{ github.event.ref }}` - **Author:** [${{ github.event.head_commit.author.username }}](https://github.com/${{ github.event.head_commit.author.username }}) - **Commit:** [${{ github.event.head_commit.id }}](${{ github.event.head_commit.url }}) - **Message:** - `${{ github.event.head_commit.message }}` - - - name: Send error notification for pull_request - if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - username: ${{ env.DISCORD_USERNAME }} - avatar_url: ${{ env.DISCORD_ERROR_AVATAR }} - title: 'Pull request build failed :confused:' - color: ${{ env.DISCORD_ERROR_COLOR }} - description: | - **Repository:** `${{ github.repository }}` - **Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}` - **Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}}) - **Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}` - **Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}` - - - name: Send success notification for pull_request - if: ${{ !contains(needs.*.result, 'failure') && github.event_name == 'pull_request' }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - username: ${{ env.DISCORD_USERNAME }} - avatar_url: ${{ env.DISCORD_EVENT_AVATAR }} - title: 'Pull request successfully build :face_with_monocle:' - color: ${{ env.DISCORD_EVENT_COLOR }} - description: | - **Repository:** `${{ github.repository }}` - **Merge:** into `${{ github.event.pull_request.base.ref }}` from `${{ github.event.pull_request.head.ref }}` - **Title:** ${{ github.event.pull_request.title }} [#${{ github.event.pull_request.number }}](${{github.event.pull_request._links.html.href}}) - **Assignees:** `${{ join(github.event.pull_request.assignees.*.login, ', ') }}` - **Labels:** `${{ join(github.event.pull_request.labels.*.name, ', ') }}` - - - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0cef6acc..a85ccefd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,47 +10,24 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Sync project labels uses: micnncim/action-label-syncer@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - config: - name: Configure - runs-on: ubuntu-latest - outputs: - config: ${{ steps.set-config.outputs.config }} - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Setup Node.js - uses: actions/setup-node@v2 - - - name: Create config - id: set-config - run: | - echo Node: $(node -v) - echo NPM: $(npm -v) - npm i semver --no-package-lock - CONFIG=$(node ./.github/scripts/config.js | sed 's/ //g') - echo "::set-output name=config::$CONFIG" - echo $CONFIG - publish: name: Publish - needs: [ sync, config ] - env: - NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }} runs-on: ubuntu-latest + env: + NODE_VERSION: 16 steps: - name: Checkout repository - uses: actions/checkout@v1 + uses: actions/checkout@v3 - name: Setup Node.js v${{ env.NODE_VERSION }} - uses: actions/setup-node@v1 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} @@ -77,16 +54,15 @@ jobs: release: name: Create Release - needs: [ publish, config ] - env: - NODE_VERSION: ${{ fromJson(needs.config.outputs.config).node.main.version }} runs-on: ubuntu-latest + env: + NODE_VERSION: 16 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: ${{ env.NODE_VERSION }} @@ -102,55 +78,3 @@ jobs: body_path: CHANGELOG.md draft: false prerelease: false - - discord: - name: Discord notification - needs: [ publish, release ] - if: ${{ always() }} - runs-on: ubuntu-latest - env: - DISCORD_USERNAME: github - DISCORD_ERROR_COLOR: 16726645 - DISCORD_ERROR_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-error.png - DISCORD_SUCCESS_COLOR: 969384 - DISCORD_SUCCESS_AVATAR: https://cdn.jsdelivr.net/gh/tagproject/art/bot/bot-success.png - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Use Node.js - uses: actions/setup-node@v2 - - - name: Get package version - run: | - node -p -e '`PACKAGE_VERSION=${require("./package.json").version}`' >> $GITHUB_ENV - node -p -e '`PACKAGE_NAME=${require("./package.json").name}`' >> $GITHUB_ENV - - - name: Send error notification - if: ${{ contains(needs.*.result, 'failure') && github.event_name == 'push' }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - username: ${{ env.DISCORD_USERNAME }} - avatar_url: ${{ env.DISCORD_ERROR_AVATAR }} - title: 'Release failed :face_with_symbols_over_mouth:' - color: ${{ env.DISCORD_ERROR_COLOR }} - description: | - **Repository:** [${{ github.repository }}](https://github.com/${{ github.repository }}/releases) - **Version:** `v${{ env.PACKAGE_VERSION }}` - - - name: Send success notification - if: ${{ !contains(needs.*.result, 'failure') && github.event_name == 'push' }} - uses: sarisia/actions-status-discord@v1 - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - nodetail: true - username: ${{ env.DISCORD_USERNAME }} - avatar_url: ${{ env.DISCORD_SUCCESS_AVATAR }} - title: 'Package successfully released :tada::tada::tada:' - color: ${{ env.DISCORD_SUCCESS_COLOR }} - description: | - **Repository:** [${{ github.repository }}](https://github.com/${{ github.repository }}/releases) - **Tag:** [v${{ env.PACKAGE_VERSION }}](https://github.com/${{ github.repository }}/releases/tag/v${{ env.PACKAGE_VERSION }}) - **NPM:** [${{ env.PACKAGE_NAME }}](https://www.npmjs.com/package/${{ env.PACKAGE_NAME }}/v/${{ env.PACKAGE_VERSION }}) diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 0d3be48e..2e1d23e6 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -11,20 +11,19 @@ on: jobs: scan: runs-on: ubuntu-latest - steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 2 - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: - config-file: ./.github/codeql/codeql-configuration.yml + config-file: ./.github/codeql/config.yml - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 10fcf417..2fbc267b 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -9,7 +9,7 @@ jobs: name: Pull Request Labeler runs-on: ubuntu-latest steps: - - uses: actions/labeler@main + - uses: actions/labeler@v4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" configuration-path: '.github/labeler.yml'