From cf16ac41e4d6f91918c114b84e2599510b880af8 Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Wed, 18 Oct 2023 16:08:56 +0200 Subject: [PATCH] Added CI --- .github/auto-merge.yml | 17 +++ .github/dependabot.yml | 31 +++++ .github/stale.yml | 78 ++++++++++++ .github/workflows/codeql.yml | 41 +++++++ .github/workflows/test-and-release.yml | 162 +++++++++++++++++++++++++ 5 files changed, 329 insertions(+) create mode 100644 .github/auto-merge.yml create mode 100644 .github/dependabot.yml create mode 100644 .github/stale.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/test-and-release.yml diff --git a/.github/auto-merge.yml b/.github/auto-merge.yml new file mode 100644 index 00000000..3f5fbe36 --- /dev/null +++ b/.github/auto-merge.yml @@ -0,0 +1,17 @@ +# Configure here which dependency updates should be merged automatically. +# The recommended configuration is the following: +- match: + # Only merge patches for production dependencies + dependency_type: production + update_type: "semver:patch" +- match: + # Except for security fixes, here we allow minor patches + dependency_type: production + update_type: "security:minor" +- match: + # and development dependencies can have a minor update, too + dependency_type: development + update_type: "semver:minor" + +# The syntax is based on the legacy dependabot v1 automerged_updates syntax, see: +# https://dependabot.com/docs/config-file/#automerged_updates \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..86b51bd7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,31 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Berlin + + - package-ecosystem: npm + directory: "/" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Berlin + open-pull-requests-limit: 7 + versioning-strategy: increase + ignore: + # Typescript should not be updated automatically, except patch updates + # it does not follow semver and minor updates are usually breaking + - dependency-name: "typescript" + update-types: ["version-update:semver-minor", "version-update:semver-major"] + + - package-ecosystem: npm + directory: "/src" + schedule: + interval: monthly + time: "04:00" + timezone: Europe/Berlin + open-pull-requests-limit: 20 + versioning-strategy: increase diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 00000000..04f9e03e --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,78 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 90 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 7 + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - enhancement + - security + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: true + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: true + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: wontfix + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs within the next 7 days. + Please check if the issue is still relevant in the most current version of the adapter + and tell us. Also check that all relevant details, logs and reproduction steps + are included and update them if needed. + Thank you for your contributions. + + Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. + Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. + Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, + und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte + enthalten sind bzw. aktualisiert diese. + Vielen Dank für Eure Unterstützung. + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +closeComment: > + This issue has been automatically closed because of inactivity. Please open a new + issue if still relevant and make sure to include all relevant details, logs and + reproduction steps. + Thank you for your contributions. + + Dieses Problem wurde aufgrund von Inaktivität automatisch geschlossen. Bitte öffnet ein + neues Issue, falls dies noch relevant ist und stellt sicher das alle relevanten Details, + Logs und Reproduktionsschritte enthalten sind. + Vielen Dank für Eure Unterstützung. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 30 + +# Limit to only `issues` or `pulls` +only: issues + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +# pulls: +# daysUntilStale: 30 +# markComment: > +# This pull request has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. + +# issues: +# exemptLabels: +# - confirmed \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..f90168cb --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,41 @@ +name: "CodeQL" + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + schedule: + - cron: "20 9 * * 0" + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ javascript ] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: +security-and-quality + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 00000000..cc78607d --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,162 @@ +# This is a composition of lint and test scripts +# Make sure to update this file along with the others + +name: Test and Release + +# Run this job on all pushes and pull requests +# as well as tags with a semantic version +on: + push: + branches: + - '*' + tags: + # normal versions + - "v?[0-9]+.[0-9]+.[0-9]+" + # pre-releases + - "v?[0-9]+.[0-9]+.[0-9]+-**" + pull_request: {} + +jobs: + # Performs quick checks before the expensive test runs + check-and-lint: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js 16.x + uses: actions/setup-node@v3.8.1 + with: + node-version: 16.x + + - name: Install Dependencies + run: npm i + + - name: Build + run: npm run build + +# - name: Perform a type check +# run: npm run check:ts +# env: +# CI: true + # - name: Lint TypeScript code + # run: npm run lint +# - name: Test package files +# run: npm run test:package + + # Runs adapter tests on all supported node versions and OSes + adapter-tests: + if: contains(github.event.head_commit.message, '[skip ci]') == false + + needs: [check-and-lint] + + runs-on: ${{ matrix.os }} + strategy: + matrix: + node-version: [18.x, 20.x] + os: [ubuntu-latest, windows-latest, macos-latest] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3.8.1 + with: + node-version: ${{ matrix.node-version }} + + - name: Install Dependencies + run: npm install + + - name: Build typescript + run: npm run build:ts + + - name: Run local tests + run: npm test + + # Deploys the final package to NPM + deploy: + needs: [adapter-tests] + + # Trigger this step only when a commit on master is tagged with a version number + if: | + contains(github.event.head_commit.message, '[skip ci]') == false && + github.event_name == 'push' && + startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Use Node.js 16.x + uses: actions/setup-node@v3.8.1 + with: + node-version: 16.x + + - name: Extract the version and commit body from the tag + id: extract_release + # The body may be multiline, therefore we need to escape some characters + run: | + VERSION="${{ github.ref }}" + VERSION=${VERSION##*/} + VERSION=${VERSION##*v} + echo "::set-output name=VERSION::$VERSION" + BODY=$(git show -s --format=%b) + BODY="${BODY//'%'/'%25'}" + BODY="${BODY//$'\n'/'%0A'}" + BODY="${BODY//$'\r'/'%0D'}" + echo "::set-output name=BODY::$BODY" + + - name: Install Dependencies + run: npm install + + - name: Build + run: npm run build + +# - name: Create a clean build +# run: npm run build + - name: Publish package to npm + run: | + npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} + npm whoami + npm publish + + - name: Create Github Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release v${{ steps.extract_release.outputs.VERSION }} + draft: false + # Prerelease versions create pre-releases on GitHub + prerelease: ${{ contains(steps.extract_release.outputs.VERSION, '-') }} + body: ${{ steps.extract_release.outputs.BODY }} + + - name: Notify Sentry.io about the release + run: | + npm i -g @sentry/cli + export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} + export SENTRY_URL=https://sentry.iobroker.net + export SENTRY_ORG=iobroker + export SENTRY_PROJECT=iobroker-matter + export SENTRY_VERSION=iobroker.matter@${{ env.VERSION }} + sentry-cli releases new $SENTRY_VERSION + sentry-cli releases finalize $SENTRY_VERSION + + - name: Notify Sentry.io about the release + run: | + npm i -g @sentry/cli + export SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} + export SENTRY_URL=https://sentry.iobroker.net + export SENTRY_ORG=iobroker + export SENTRY_PROJECT=iobroker-matter-react + export SENTRY_VERSION=iobroker.matter-react@${{ env.VERSION }} + sentry-cli releases new $SENTRY_VERSION + sentry-cli releases finalize $SENTRY_VERSION + + # Add the following line BEFORE finalize if repositories are connected in Sentry + # sentry-cli releases set-commits $SENTRY_VERSION --auto + + # Add the following line BEFORE finalize if sourcemap uploads are needed + # sentry-cli releases files $SENTRY_VERSION upload-sourcemaps build/ \ No newline at end of file