Browse Source

ci: check for change tag (#7149)

* ci: check for change tag

* fix workflow

* Update .scripts/ci/check-change-tags.js

* feat: also check if tag is known

seems like covector does not check that so we can do it here for now

* remove push run

* only check changed files

* add missing tag

---------

Co-authored-by: Lucas Fernandes Nogueira <lucas@tauri.studio>
Amr Bashir 2 years ago
parent
commit
fc2e4083b0
42 changed files with 188 additions and 48 deletions
  1. 1 1
      .changes/api-js-os-locale.md
  2. 1 1
      .changes/api-rs-os-locale.md
  3. 1 1
      .changes/build-enhance-features-check.md
  4. 1 1
      .changes/cleanup-app-bundle.md
  5. 2 2
      .changes/cli-windows-arm64.md
  6. 1 1
      .changes/config-require-literal_leading_dot.md
  7. 2 2
      .changes/core-global-shortcut-panics.md
  8. 1 1
      .changes/core-window-config.md
  9. 1 1
      .changes/core-windows-notification-sound.md
  10. 3 3
      .changes/deb-custom-desktop-file-config.md
  11. 2 2
      .changes/enhance-allowlist-injection.md
  12. 1 1
      .changes/expose-test.md
  13. 1 1
      .changes/mime-type.md
  14. 1 1
      .changes/nsis-custom-language-files.md
  15. 1 1
      .changes/nsis-custom-template.md
  16. 1 1
      .changes/nsis-downgrades.md
  17. 1 1
      .changes/nsis-install-mode-args.md
  18. 1 1
      .changes/nsis-passive-mode.md
  19. 1 1
      .changes/nsis-restart-flag.md
  20. 1 1
      .changes/nsis-silent-kill.md
  21. 1 1
      .changes/nsis-silent-shortcuts.md
  22. 1 1
      .changes/nsis-uninstall-wix.md
  23. 1 1
      .changes/remove-attohttpc-bundler.md
  24. 1 1
      .changes/remove-attohttpc-core.md
  25. 2 2
      .changes/rustls-default.md
  26. 1 1
      .changes/txt-mime-type.md
  27. 32 0
      .github/workflows/check-change-tags.yml
  28. 0 10
      .github/workflows/check-generated-files.yml
  29. 1 1
      .github/workflows/check-license-header.yml
  30. 1 0
      .scripts/cargo-check.ps1
  31. 1 0
      .scripts/cargo-check.sh
  32. 79 0
      .scripts/ci/check-change-tags.js
  33. 20 5
      .scripts/ci/check-license-header.js
  34. 4 0
      .scripts/ci/has-diff.sh
  35. 5 0
      .scripts/ci/pack-cli.sh
  36. 1 0
      .scripts/covector/package-latest-version.js
  37. 1 0
      .scripts/covector/sync-cli-metadata.js
  38. 4 0
      .scripts/docker/build.sh
  39. 1 0
      .scripts/setup.ps1
  40. 1 0
      .scripts/setup.sh
  41. 1 0
      .scripts/update-lockfiles.sh
  42. 4 0
      .scripts/utils/batch_to_exe.cmd

+ 1 - 1
.changes/api-js-os-locale.md

@@ -1,5 +1,5 @@
 ---
-'@tauri-apps/api': 'patch'
+'@tauri-apps/api': 'patch:feat'
 ---
 
 Add `locale` function in the `os` module to get the system locale.

+ 1 - 1
.changes/api-rs-os-locale.md

@@ -1,5 +1,5 @@
 ---
-"tauri": "patch"
+'tauri': 'patch:feat'
 ---
 
 Add `tauri::api::os::locale` function to get the system locale.

+ 1 - 1
.changes/build-enhance-features-check.md

@@ -1,5 +1,5 @@
 ---
-"tauri-build": patch
+'tauri-build': patch:enhance
 ---
 
 Enhance Cargo features check.

+ 1 - 1
.changes/cleanup-app-bundle.md

@@ -1,5 +1,5 @@
 ---
-"tauri-bundler": patch
+'tauri-bundler': patch:enhance
 ---
 
 Remove macOS app bundles from the output if they are not requested by the user.

+ 2 - 2
.changes/cli-windows-arm64.md

@@ -1,6 +1,6 @@
 ---
-'tauri-cli': minor
-'@tauri-apps/cli': minor
+'tauri-cli': minor:feat
+'@tauri-apps/cli': minor:feat
 ---
 
 Provide prebuilt CLIs for Windows ARM64 targets.

+ 1 - 1
.changes/config-require-literal_leading_dot.md

@@ -1,5 +1,5 @@
 ---
-'tauri-utils': 'minor'
+'tauri-utils': 'minor:feat'
 ---
 
 Add option to configure `require_literal_leading_dot` on `fs` and `asset` protcol scopes.

+ 2 - 2
.changes/core-global-shortcut-panics.md

@@ -1,6 +1,6 @@
 ---
-'tauri': 'patch'
-'tauri-runtime-wry': 'patch'
+'tauri': 'patch:bug'
+'tauri-runtime-wry': 'patch:bug'
 ---
 
 Fix panics when registering an invalid global shortcuts or checking it is registered and return proper errors instead.

+ 1 - 1
.changes/core-window-config.md

@@ -1,5 +1,5 @@
 ---
-'tauri': 'patch'
+'tauri': 'patch:bug'
 ---
 
 Fix some configurations not applied when creating the window through Javascript.

+ 1 - 1
.changes/core-windows-notification-sound.md

@@ -1,5 +1,5 @@
 ---
-"tauri": "patch"
+'tauri': 'patch:bug'
 ---
 
 Play a sound when showing a notification on Windows.

+ 3 - 3
.changes/deb-custom-desktop-file-config.md

@@ -1,7 +1,7 @@
 ---
-"tauri-utils": patch
-"tauri-cli": patch
-"@tauri-apps/cli": patch
+'tauri-utils': patch:feat
+'tauri-cli': patch:feat
+'@tauri-apps/cli': patch:feat
 ---
 
 Added the `desktop_template` option on `tauri.conf.json > tauri > bundle > deb`.

+ 2 - 2
.changes/enhance-allowlist-injection.md

@@ -1,6 +1,6 @@
 ---
-"tauri-cli": patch
-"@tauri-apps/cli": patch
+'tauri-cli': patch:enhance
+'@tauri-apps/cli': patch:enhance
 ---
 
 Enhance injection of Cargo features.

+ 1 - 1
.changes/expose-test.md

@@ -1,5 +1,5 @@
 ---
-"tauri": patch
+"tauri": 'minor:feat'
 ---
 
 Expose the `test` module behind the `test` Cargo feature.

+ 1 - 1
.changes/mime-type.md

@@ -1,5 +1,5 @@
 ---
-'tauri-utils': 'patch'
+'tauri-utils': 'patch:feat'
 ---
 
 Add `MimeType::parse_with_fallback` and `MimeType::parse_from_uri_with_fallback`

+ 1 - 1
.changes/nsis-custom-language-files.md

@@ -1,6 +1,6 @@
 ---
 'tauri-bundler': 'minor:feat'
-'tauri-utils': 'minor'
+'tauri-utils': 'minor:feat'
 'tauri-cli': 'minor:feat'
 ---
 

+ 1 - 1
.changes/nsis-custom-template.md

@@ -1,5 +1,5 @@
 ---
-'tauri-utils': 'minor'
+'tauri-utils': 'minor:feat'
 'tauri-bundler': 'minor:feat'
 'tauri-cli': 'minor:feat'
 '@tauri-apps/cli': 'minor:feat'

+ 1 - 1
.changes/nsis-downgrades.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': 'patch'
+'tauri-bundler': 'patch:bug'
 ---
 
 Fix NSIS installer disabling `do not uninstall` button and silent installer aborting, if `allowDowngrades` was disabled even when we are not downgrading.

+ 1 - 1
.changes/nsis-install-mode-args.md

@@ -1,5 +1,5 @@
 ---
-'tauri-utils': 'patch'
+'tauri-utils': 'patch:feat'
 ---
 
 Add `WindowsUpdateInstallMode::nsis_args`

+ 1 - 1
.changes/nsis-passive-mode.md

@@ -1,5 +1,5 @@
 ---
-'tauri': 'minor'
+'tauri': 'minor:enhance'
 ---
 
 Support `passive` mode for NSIS updater.

+ 1 - 1
.changes/nsis-restart-flag.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': 'minor'
+'tauri-bundler': 'minor:feat'
 ---
 
 For NSIS, Add support for `/P` to install or uninstall in passive mode, `/R` to (re)start the app and `/NS` to disable creating shortcuts in `silent` and `passive` modes.

+ 1 - 1
.changes/nsis-silent-kill.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': 'minor'
+'tauri-bundler': 'minor:enhance'
 ---
 
 NSIS `silent` and `passive` installer/updater will auto-kill the app if its running.

+ 1 - 1
.changes/nsis-silent-shortcuts.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': 'patch'
+'tauri-bundler': 'patch:bug'
 ---
 
 Fix NSIS silent installer not creating Desktop and StartMenu shortcuts. Pass `/NS` to disable creating them.

+ 1 - 1
.changes/nsis-uninstall-wix.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': 'minor'
+'tauri-bundler': 'minor:enhance'
 ---
 
 NSIS installer will now check if a previous WiX `.msi` installation exist and will prompt users to uninstall it.

+ 1 - 1
.changes/remove-attohttpc-bundler.md

@@ -1,5 +1,5 @@
 ---
-'tauri-bundler': patch
+'tauri-bundler': patch:enhance
 ---
 
 Remove `attohttpc` in favor of `ureq`.

+ 1 - 1
.changes/remove-attohttpc-core.md

@@ -1,5 +1,5 @@
 ---
-'tauri': patch
+'tauri': patch:enhance
 ---
 
 Remove `attohttpc` in favor of `reqwest`.

+ 2 - 2
.changes/rustls-default.md

@@ -1,6 +1,6 @@
 ---
-'tauri-cli': patch
-'@tauri-apps/cli': patch
+'tauri-cli': patch:enhance
+'@tauri-apps/cli': patch:enhance
 ---
 
 Add `rustls` as default Cargo feature.

+ 1 - 1
.changes/txt-mime-type.md

@@ -1,5 +1,5 @@
 ---
-"tauri-utils": patch
+'tauri-utils': patch:feat
 ---
 
 Correctly determine MIME type of `.txt` files.

+ 32 - 0
.github/workflows/check-change-tags.yml

@@ -0,0 +1,32 @@
+# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: MIT
+
+name: check change tags
+
+on:
+  pull_request:
+    paths:
+      - '.changes/*.md'
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: true
+
+jobs:
+  check:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+
+      - uses: dorny/paths-filter@v2
+        id: filter
+        with:
+          list-files: shell
+          filters: |
+            changes:
+              - '.changes/*.md'
+
+      - name: check
+        run: node ./.scripts/ci/check-change-tags.js ${{ steps.filter.outputs.changes_files }}
+        if: ${{ steps.filter.outputs.changes == 'true' }}

+ 0 - 10
.github/workflows/check-generated-files.yml

@@ -13,16 +13,6 @@ on:
       - 'core/tauri-utils/src/config.rs'
       - 'tooling/cli/schema.json'
       - 'core/tauri-config-schema/schema.json'
-  push:
-    branches:
-      - dev
-    paths:
-      - '.github/workflows/check-generated-files.yml'
-      - 'tooling/api/src/**'
-      - 'core/tauri/scripts/bundle.global.js'
-      - 'core/tauri-utils/src/config.rs'
-      - 'tooling/cli/schema.json'
-      - 'core/tauri-config-schema/schema.json'
 
 concurrency:
   group: ${{ github.workflow }}-${{ github.ref }}

+ 1 - 1
.github/workflows/check-license-header.yml

@@ -25,4 +25,4 @@ jobs:
               - added: '**'
       - name: check header license on new files
         if: ${{ steps.filter.outputs.added == 'true' }}
-        run: node check-license-header.js ${{ steps.filter.outputs.added_files }}
+        run: node ./.scripts/ci/check-license-header.js ${{ steps.filter.outputs.added_files }}

+ 1 - 0
.scripts/cargo-check.ps1

@@ -1,4 +1,5 @@
 #!/usr/bin/env pwsh
+
 # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-License-Identifier: MIT

+ 1 - 0
.scripts/cargo-check.sh

@@ -1,4 +1,5 @@
 #!/usr/bin/env sh
+
 # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-License-Identifier: MIT

+ 79 - 0
.scripts/ci/check-change-tags.js

@@ -0,0 +1,79 @@
+#!/usr/bin/env node
+
+// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-License-Identifier: MIT
+
+const fs = require('fs')
+const path = require('path')
+const ignorePackages = [
+  'tauri-macros',
+  'tauri-codegen',
+  'tauri-runtime',
+  'tauri-runtime-wry',
+  'tauri-driver'
+]
+
+const covectorConfig = JSON.parse(
+  fs.readFileSync('.changes/config.json', 'utf8')
+)
+const tags = Object.keys(covectorConfig.changeTags)
+
+const missingTagsFiles = {}
+const unknownTagsFiles = {}
+
+function checkChangeFiles(changeFiles) {
+  for (const file of changeFiles) {
+    const content = fs.readFileSync(file, 'utf8')
+    const [frontMatter] = /^---[\s\S.]*---\n/i.exec(content)
+    const packages = frontMatter
+      .split('\n')
+      .filter((l) => !(l === '---' || !l))
+      .map((l) => l.replace(/('|")/g, '').split(':'))
+
+    for (const [package, _, tag] of packages) {
+      if (!tag) {
+        if (ignorePackages.includes(package)) continue
+
+        if (!missingTagsFiles[file]) missingTagsFiles[file] = []
+        missingTagsFiles[file].push(package)
+      } else if (!tags.includes(tag)) {
+        if (!unknownTagsFiles[file]) unknownTagsFiles[file] = []
+        unknownTagsFiles[file].push({ package, tag })
+      }
+    }
+  }
+  const missingTagsEntries = Object.entries(missingTagsFiles)
+  const unknownTagsEntries = Object.entries(unknownTagsFiles)
+  if (missingTagsEntries.length > 0 || unknownTagsEntries.length > 0) {
+    for (const [file, packages] of missingTagsEntries) {
+      for (const package of packages) {
+        console.error(
+          `Package \`${package}\` is missing a change tag in ${file} `
+        )
+      }
+    }
+
+    for (const [file, packages] of unknownTagsEntries) {
+      for (const { package, tag } of packages) {
+        console.error(
+          `Package \`${package}\` has an uknown change tag ${tag} in ${file} `
+        )
+      }
+    }
+
+    process.exit(1)
+  }
+}
+
+const [_bin, _script, ...files] = process.argv
+
+if (files.length > 0) {
+  checkChangeFiles(files.filter((f) => f.toLowerCase() !== 'readme.md'))
+} else {
+  const changeFiles = fs
+    .readdirSync('.changes')
+    .filter((f) => f.endsWith('.md') && f.toLowerCase() !== 'readme.md')
+    .map((p) => path.join('.changes', p))
+  checkChangeFiles(changeFiles)
+}

+ 20 - 5
check-license-header.js → .scripts/ci/check-license-header.js

@@ -1,3 +1,5 @@
+#!/usr/bin/env node
+
 // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT
@@ -9,13 +11,22 @@ const readline = require('readline')
 const header = `Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 SPDX-License-Identifier: Apache-2.0
 SPDX-License-Identifier: MIT`
-const bundlerLicense = '// Copyright 2016-2019 Cargo-Bundle developers <https://github.com/burtonageo/cargo-bundle>'
+const bundlerLicense =
+  '// Copyright 2016-2019 Cargo-Bundle developers <https://github.com/burtonageo/cargo-bundle>'
 
 const extensions = ['.rs', '.js', '.ts', '.yml']
-const ignore = ['target', 'templates', 'node_modules', 'gen', 'dist', 'bundle.js', 'bundle.global.js']
+const ignore = [
+  'target',
+  'templates',
+  'node_modules',
+  'gen',
+  'dist',
+  'bundle.js',
+  'bundle.global.js'
+]
 
 async function checkFile(file) {
-  if (extensions.some(e => file.endsWith(e))) {
+  if (extensions.some((e) => file.endsWith(e))) {
     const fileStream = fs.createReadStream(file)
     const rl = readline.createInterface({
       input: fileStream,
@@ -26,7 +37,11 @@ async function checkFile(file) {
     let i = 0
     for await (let line of rl) {
       // ignore empty lines, allow shebang and bundler license
-      if (line.length === 0 || line.startsWith("#!") || line === bundlerLicense) {
+      if (
+        line.length === 0 ||
+        line.startsWith('#!') ||
+        line === bundlerLicense
+      ) {
         continue
       }
 
@@ -93,7 +108,7 @@ if (files.length > 0) {
 
   run()
 } else {
-  check('.').then(missing => {
+  check('.').then((missing) => {
     if (missing.length > 0) {
       console.log(missing.join('\n'))
       process.exit(1)

+ 4 - 0
.scripts/ci/has-diff.sh

@@ -1,5 +1,9 @@
 #!/bin/bash
 
+# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: MIT
+
 if git diff --quiet --ignore-submodules HEAD
 then
   echo "working directory is clean"

+ 5 - 0
.scripts/ci/pack-cli.sh

@@ -1,4 +1,9 @@
 #!/bin/bash
+
+# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: MIT
+
 set -euxo pipefail
 
 for o in outputs/*; do

+ 1 - 0
.scripts/covector/package-latest-version.js

@@ -1,4 +1,5 @@
 #!/usr/bin/env node
+
 // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT

+ 1 - 0
.scripts/covector/sync-cli-metadata.js

@@ -1,4 +1,5 @@
 #!/usr/bin/env node
+
 // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 // SPDX-License-Identifier: Apache-2.0
 // SPDX-License-Identifier: MIT

+ 4 - 0
.scripts/docker/build.sh

@@ -1,3 +1,7 @@
 #!/bin/sh
 
+# Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+# SPDX-License-Identifier: Apache-2.0
+# SPDX-License-Identifier: MIT
+
 docker build -t aarch64-unknown-linux-gnu:latest --file .docker/cross/aarch64.Dockerfile .docker/cross

+ 1 - 0
.scripts/setup.ps1

@@ -1,4 +1,5 @@
 #!/usr/bin/env pwsh
+
 # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-License-Identifier: MIT

+ 1 - 0
.scripts/setup.sh

@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
+
 # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-License-Identifier: MIT

+ 1 - 0
.scripts/update-lockfiles.sh

@@ -1,4 +1,5 @@
 #!/usr/bin/env sh
+
 # Copyright 2019-2023 Tauri Programme within The Commons Conservancy
 # SPDX-License-Identifier: Apache-2.0
 # SPDX-License-Identifier: MIT

+ 4 - 0
.scripts/utils/batch_to_exe.cmd

@@ -1,3 +1,7 @@
+: Copyright 2019-2023 Tauri Programme within The Commons Conservancy
+: SPDX-License-Identifier: Apache-2.0
+: SPDX-License-Identifier: MIT
+
 @ECHO OFF
 
 REM Copyright 2019-2023 Tauri Programme within The Commons Conservancy