diff --git a/.github/problemMatchers/eslint.json b/.github/problemMatchers/eslint.json deleted file mode 100644 index e61137a2..00000000 --- a/.github/problemMatchers/eslint.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "eslint-stylish", - "pattern": [ - { - "regexp": "^([^\\s].*)$", - "file": 1 - }, - { - "regexp": "^\\s+(\\d+):(\\d+)\\s+(error|warning|info)\\s+(.*)\\s\\s+(.*)$", - "line": 1, - "column": 2, - "severity": 3, - "message": 4, - "code": 5, - "loop": true - } - ] - } - ] -} diff --git a/.github/problemMatchers/tsc.json b/.github/problemMatchers/tsc.json deleted file mode 100644 index 5d1900e9..00000000 --- a/.github/problemMatchers/tsc.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "problemMatcher": [ - { - "owner": "tsc", - "pattern": [ - { - "regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$", - "file": 1, - "location": 2, - "severity": 3, - "code": 4, - "message": 5 - } - ] - } - ] -} diff --git a/.github/workflows/auto-deprecate.yml b/.github/workflows/auto-deprecate.yml index df48923a..d3ddf4f7 100644 --- a/.github/workflows/auto-deprecate.yml +++ b/.github/workflows/auto-deprecate.yml @@ -7,19 +7,8 @@ on: jobs: auto-deprecate: name: NPM Auto Deprecate - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Deprecate versions - run: yarn npm-deprecate - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main + with: + script-name: npm-deprecate + secrets: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 286fefca..bad2e0e8 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -1,4 +1,4 @@ -name: Code Scanning +name: Code scanning on: push: @@ -11,18 +11,6 @@ on: - cron: '30 1 * * 0' jobs: - CodeQL: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + codeql: + name: Analysis + uses: sapphiredev/.github/.github/workflows/reusable-codeql.yml@main diff --git a/.github/workflows/continuous-delivery.yml b/.github/workflows/continuous-delivery.yml index f538897e..a77a6717 100644 --- a/.github/workflows/continuous-delivery.yml +++ b/.github/workflows/continuous-delivery.yml @@ -5,15 +5,18 @@ on: inputs: prNumber: description: The number of the PR that is being deployed - required: true + required: false + type: string ref: description: The branch that is being deployed. Should be a branch on the given repository required: false default: main + type: string repository: description: The {owner}/{repository} that is being deployed. required: false default: sapphiredev/pieces + type: string push: branches: - main @@ -21,35 +24,10 @@ on: jobs: Publish: name: Publish Next to npm - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - with: - fetch-depth: 0 - repository: ${{ github.event.inputs.repository || 'sapphiredev/pieces' }} - ref: ${{ github.event.inputs.ref || 'main' }} - - name: Add TypeScript problem matcher - run: echo "::add-matcher::.github/problemMatchers/tsc.json" - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.yarnpkg.com/ - - name: Install Dependencies - run: yarn --immutable - - name: Bump Version & Publish - run: | - # Resolve the tag to be used. "next" for push events, "pr-{prNumber}" for dispatch events. - TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}') - - yarn config set npmAuthToken ${NODE_AUTH_TOKEN} - yarn config set npmPublishRegistry "https://registry.yarnpkg.com" - - yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)" --skip-changelog - - yarn npm publish --tag ${TAG} - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: sapphiredev/.github/.github/workflows/reusable-continuous-delivery.yml@main + with: + pr-number: ${{ github.event.inputs.prNumber }} + ref: ${{ github.event.inputs.ref }} + repository: ${{ github.event.inputs.repository }} + secrets: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d3fc1134..5f09fcad 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,4 +1,4 @@ -name: Continuous Integration +name: CI on: push: @@ -7,63 +7,29 @@ on: pull_request: jobs: - Linting: + linting: name: Linting - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Add problem matcher - run: echo "::add-matcher::.github/problemMatchers/eslint.json" - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Run ESLint - run: yarn lint --fix=false + uses: sapphiredev/.github/.github/workflows/reusable-lint.yml@main docs: - name: Generate Documentation - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Generate Documentation - run: yarn docs + name: Docgen + uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main + with: + script-name: docs - BuildingAndTesting: - name: Building and Testing with node v${{ matrix.node }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - node: [18, 19, 20, 21] - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Add problem matcher - run: echo "::add-matcher::.github/problemMatchers/tsc.json" - - name: Use Node.js ${{ matrix.node }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node }} - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Typecheck And Build Code - run: yarn typecheck && yarn build - - name: Run tests - run: yarn test + build: + name: Building + uses: sapphiredev/.github/.github/workflows/reusable-build.yml@main + + test: + name: Tests + uses: sapphiredev/.github/.github/workflows/reusable-tests.yml@main + with: + enable-sonar: true + secrets: + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + typecheck: + name: Typecheck + uses: sapphiredev/.github/.github/workflows/reusable-typecheck.yml@main diff --git a/.github/workflows/deprecate-on-merge.yml b/.github/workflows/deprecate-on-merge.yml index 05aef98f..ae50cadc 100644 --- a/.github/workflows/deprecate-on-merge.yml +++ b/.github/workflows/deprecate-on-merge.yml @@ -8,20 +8,8 @@ on: jobs: deprecate-on-merge: name: NPM Deprecate PR versions On Merge - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Deprecate versions - run: yarn npm-deprecate --name "*pr-${PR_NUMBER}*" -d -v - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - PR_NUMBER: ${{ github.event.number }} + uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main + with: + script-name: npm-deprecate --name "*pr-${{ github.event.number }}*" -d -v + secrets: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index bc09d20e..d34092e7 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -7,105 +7,10 @@ on: tags: - 'v*' -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: true - jobs: - build: - name: Build Documentation - runs-on: ubuntu-latest - if: github.repository_owner == 'sapphiredev' - outputs: - NAME: ${{ steps.env.outputs.NAME }} - TYPE: ${{ steps.env.outputs.TYPE }} - SHA: ${{ steps.env.outputs.SHA }} - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.npmjs.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Build Documentation - run: yarn docs - - name: Upload Documentation Artifacts - uses: actions/upload-artifact@v4 - with: - name: docs - path: docs/api.json - - name: Set Output - id: env - run: | - echo "NAME=${GITHUB_REF_NAME}" >> $GITHUB_OUTPUT - echo "TYPE=${GITHUB_REF_TYPE}" >> $GITHUB_OUTPUT - echo "SHA=${GITHUB_SHA}" >> $GITHUB_OUTPUT - upload: - name: Upload Documentation - needs: build - runs-on: ubuntu-latest - env: - NAME: ${{ needs.build.outputs.NAME }} - TYPE: ${{ needs.build.outputs.TYPE }} - SHA: ${{ needs.build.outputs.SHA }} - steps: - - name: Checkout Project - uses: actions/checkout@v4 - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.yarnpkg.org/ - - name: Install Dependencies - run: yarn --immutable - - name: Download Documentation Artifacts - uses: actions/download-artifact@v4 - with: - name: docs - path: docs - - name: Checkout Documentation Project - uses: actions/checkout@v4 - with: - repository: 'sapphiredev/docs' - token: ${{ secrets.SKYRA_TOKEN }} - path: 'out' - - - name: Move Documentation - if: ${{ env.TYPE == 'tag' }} - env: - SEMVER: ${{ env.NAME }} - run: | - mkdir -p out/pieces - mv docs/api.json out/docs/pieces/${SEMVER}.json - - name: Move Documentation - if: ${{ env.TYPE == 'branch' }} - run: | - mkdir -p out/pieces - mv docs/api.json out/docs/pieces/${NAME}.json - - - name: Commit & Push - uses: nick-fields/retry@v3 - with: - max_attempts: 3 - retry_on: error - timeout_minutes: 1 - command: | - cd out - git add . - if git diff-index --quiet HEAD --; then - echo "No changes to commit, exiting with code 0" - exit 0; - else - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - git config rebase.autostash true - git config pull.rebase true - git commit -m "docs(pieces): build for ${TYPE} ${NAME}: ${SHA}" || true - git pull - git push - fi + docgen: + uses: sapphiredev/.github/.github/workflows/reusable-docgen.yml@main + with: + project-name: pieces + secrets: + SKYRA_TOKEN: ${{ secrets.SKYRA_TOKEN }} diff --git a/.github/workflows/labelsync.yml b/.github/workflows/labelsync.yml index 97a27d9e..e7973363 100644 --- a/.github/workflows/labelsync.yml +++ b/.github/workflows/labelsync.yml @@ -7,17 +7,4 @@ on: jobs: label_sync: - name: Automatic Label Synchronization - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v4 - with: - sparse-checkout: .github/labels.yml - sparse-checkout-cone-mode: false - repository: 'sapphiredev/.github' - - name: Run Label Sync - uses: crazy-max/ghaction-github-labeler@v5 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - yaml-file: .github/labels.yml + uses: sapphiredev/.github/.github/workflows/reusable-labelsync.yml@main diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 065ed647..d1271a5b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,40 +6,9 @@ on: jobs: PublishPackage: name: Publish @sapphire/pieces - runs-on: ubuntu-latest - if: github.repository_owner == 'sapphiredev' - steps: - - name: Checkout Project - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: main - token: ${{ secrets.SKYRA_TOKEN }} - - name: Use Node.js v20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: yarn - registry-url: https://registry.yarnpkg.com/ - - name: Install Dependencies - run: yarn --immutable - - name: Configure Git - run: | - git remote set-url origin "https://${GITHUB_TOKEN}:x-oauth-basic@github.com/${GITHUB_REPOSITORY}.git" - git config --local user.email "${GITHUB_EMAIL}" - git config --local user.name "${GITHUB_USER}" - env: - GITHUB_USER: github-actions[bot] - GITHUB_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Bump Versions and make release - run: yarn bump - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Publish to NPM - run: | - yarn config set npmAuthToken ${NODE_AUTH_TOKEN} - yarn config set npmPublishRegistry "https://registry.yarnpkg.com" - yarn npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + uses: sapphiredev/.github/.github/workflows/reusable-publish.yml@main + with: + project-name: '@sapphire/pieces' + secrets: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + SKYRA_TOKEN: ${{ secrets.SKYRA_TOKEN }} diff --git a/.github/workflows/release-crosspost.yml b/.github/workflows/release-crosspost.yml deleted file mode 100644 index 06e50eb3..00000000 --- a/.github/workflows/release-crosspost.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Release Crosspost - -on: - release: - types: - - published - -jobs: - Crosspost: - name: Release Crosspost - runs-on: ubuntu-latest - steps: - - name: Parse release name - id: get_release_name - run: echo "release_name=${RELEASE:-$TAG}" >> $GITHUB_OUTPUT - env: - RELEASE: ${{ github.event.release.name }} - TAG: ${{ github.event.release.tag_name }} - - - name: Send Release Message - id: crosspost_action - uses: kludge-cs/gitcord-release-changelogger@5592170408dc081d7cb6a74ce025911bd1fcb7c3 # renovate: tag=v3.0.0 - with: - webhook-url: ${{ secrets.RELEASE_WEBHOOK }} - release-body: ${{ github.event.release.body }} - release-name: ${{ steps.get_release_name.outputs.release_name }} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..c6188cf2 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1 @@ +sonar.projectKey=sapphiredev_pieces_a16e3374-bcd2-483d-a2ac-6720a6ae7d67