From 672152d1ff6491cfac2a9177806fdbeebf9bc58b Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 11:47:23 +0000 Subject: [PATCH 01/15] github workflow for module lint --- .github/workflows/main.yml | 4 +++ .github/workflows/module-lint.yml | 37 ++++++++++++++++++++++++++++ src/rules/require-valid-changelog.ts | 16 ++++++++---- 3 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/module-lint.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8fa96e6..da46a6e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -23,6 +23,10 @@ jobs: name: Build, lint, and test uses: ./.github/workflows/build-lint-test.yml + module-lint: + name: Module Lint + uses: ./.github/workflows/module-lint.yml + all-jobs-completed: name: All jobs completed runs-on: ubuntu-latest diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml new file mode 100644 index 0000000..fb3a072 --- /dev/null +++ b/.github/workflows/module-lint.yml @@ -0,0 +1,37 @@ +name: Module Lint + +on: + workflow_call: + +jobs: + prepare: + name: Prepare + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version-file: '.nvmrc' + cache: 'yarn' + - name: Install Yarn dependencies + run: yarn --immutable + + module-lint: + name: Module Lint + runs-on: ubuntu-latest + needs: + - prepare + strategy: + matrix: + node-version: [16.x, 18.x, 20.x] + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn --immutable --immutable-cache + - run: yarn run-tool + diff --git a/src/rules/require-valid-changelog.ts b/src/rules/require-valid-changelog.ts index da6945a..cb645e0 100644 --- a/src/rules/require-valid-changelog.ts +++ b/src/rules/require-valid-changelog.ts @@ -2,7 +2,11 @@ import { ChangelogFormattingError, validateChangelog, } from '@metamask/auto-changelog'; -import { getErrorMessage, isErrorWithCode } from '@metamask/utils/node'; +import { + getErrorMessage, + isErrorWithCode, + isErrorWithMessage, +} from '@metamask/utils/node'; import { buildRule } from './build-rule'; import { PackageManifestSchema, RuleName } from './types'; @@ -28,10 +32,12 @@ export default buildRule({ }); return pass(); } catch (error) { - if (isErrorWithCode(error) && error.code === 'ERR_INVALID_JSON_FILE') { - throw new Error( - 'The package does not have a well-formed manifest. This is not the fault of the changelog, but this rule requires a valid package manifest.', - ); + if ( + isErrorWithCode(error) && + isErrorWithMessage(error) && + error.code === 'ERR_INVALID_JSON_FILE' + ) { + throw new Error(error.message); } else if (error instanceof ChangelogFormattingError) { return fail([ { From 04081fe35c1fc79c815a07284f4c23b604228afe Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 11:58:52 +0000 Subject: [PATCH 02/15] lint error fixed --- .github/workflows/module-lint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index fb3a072..9f4debe 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -34,4 +34,3 @@ jobs: cache: 'yarn' - run: yarn --immutable --immutable-cache - run: yarn run-tool - From 20ffed8936d1c13f4bdc17225072c54d029837b9 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 12:08:17 +0000 Subject: [PATCH 03/15] gh token added --- .github/workflows/module-lint.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 9f4debe..eff1423 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -32,5 +32,8 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'yarn' + - uses: MetaMask/action-module-lint@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: yarn --immutable --immutable-cache - run: yarn run-tool From 119df5fe678f5210388443ddf8f4694278d7be66 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 12:12:09 +0000 Subject: [PATCH 04/15] gh token added --- .github/workflows/module-lint.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index eff1423..4804bbd 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -32,8 +32,7 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'yarn' - - uses: MetaMask/action-module-lint@v3 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: yarn --immutable --immutable-cache - run: yarn run-tool + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From c876e30bf88acc8b6fe2e7da39b438a409c3e502 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 12:17:13 +0000 Subject: [PATCH 05/15] revert error msg changes --- src/rules/require-valid-changelog.ts | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/rules/require-valid-changelog.ts b/src/rules/require-valid-changelog.ts index cb645e0..da6945a 100644 --- a/src/rules/require-valid-changelog.ts +++ b/src/rules/require-valid-changelog.ts @@ -2,11 +2,7 @@ import { ChangelogFormattingError, validateChangelog, } from '@metamask/auto-changelog'; -import { - getErrorMessage, - isErrorWithCode, - isErrorWithMessage, -} from '@metamask/utils/node'; +import { getErrorMessage, isErrorWithCode } from '@metamask/utils/node'; import { buildRule } from './build-rule'; import { PackageManifestSchema, RuleName } from './types'; @@ -32,12 +28,10 @@ export default buildRule({ }); return pass(); } catch (error) { - if ( - isErrorWithCode(error) && - isErrorWithMessage(error) && - error.code === 'ERR_INVALID_JSON_FILE' - ) { - throw new Error(error.message); + if (isErrorWithCode(error) && error.code === 'ERR_INVALID_JSON_FILE') { + throw new Error( + 'The package does not have a well-formed manifest. This is not the fault of the changelog, but this rule requires a valid package manifest.', + ); } else if (error instanceof ChangelogFormattingError) { return fail([ { From d478e58f813f4ef361357af50ba015b6ec8c5b5f Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 12:36:25 +0000 Subject: [PATCH 06/15] output separately for each project --- .github/workflows/module-lint.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 4804bbd..511fc24 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -25,6 +25,8 @@ jobs: strategy: matrix: node-version: [16.x, 18.x, 20.x] + projects: + ['auto-changelog', 'create-release-branch', 'module-lint', 'utils'] steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} @@ -33,6 +35,6 @@ jobs: node-version: ${{ matrix.node-version }} cache: 'yarn' - run: yarn --immutable --immutable-cache - - run: yarn run-tool + - run: yarn run-tool ${{ matrix.projects }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1f49e4b50c7821f79e82f2541a7752a1cfdb6594 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 27 Mar 2024 12:44:11 +0000 Subject: [PATCH 07/15] require clean wd --- .github/workflows/module-lint.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 511fc24..51870dc 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -38,3 +38,10 @@ jobs: - run: yarn run-tool ${{ matrix.projects }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Require clean working directory + shell: bash + run: | + if ! git diff --exit-code; then + echo "Working tree dirty at end of job" + exit 1 + fi From 7e171824dc0b6b98bdee091124e9d269d471e8a1 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Fri, 29 Mar 2024 10:34:29 +0000 Subject: [PATCH 08/15] non zero exit in case of fails or errors --- CHANGELOG.md | 2 +- package.json | 8 ++++---- src/main.ts | 15 +++++++++++++-- src/report-project-lint-result.ts | 3 +++ yarn.lock | 6 +++--- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a50bc3..99ced06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,4 +6,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -[Unreleased]: https://github.com/MetaMask/module-lint/ +[Unreleased]: https://github.com/MetaMask/module-lint-fork/ diff --git a/package.json b/package.json index c74b326..4522b3e 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "@metamask/module-lint", + "name": "@metamask/module-lint-fork", "version": "0.0.0", "description": "Analyzes one or more repos for divergence from a template repo", - "homepage": "https://github.com/MetaMask/module-lint#readme", + "homepage": "https://github.com/MetaMask/module-lint-fork#readme", "bugs": { - "url": "https://github.com/MetaMask/module-lint/issues" + "url": "https://github.com/MetaMask/module-lint-fork/issues" }, "repository": { "type": "git", - "url": "https://github.com/MetaMask/module-lint.git" + "url": "https://github.com/MetaMask/module-lint-fork.git" }, "sideEffects": false, "exports": { diff --git a/src/main.ts b/src/main.ts index 777e8ae..d6b4781 100644 --- a/src/main.ts +++ b/src/main.ts @@ -71,13 +71,18 @@ export async function main({ outputLogger, }); - await lintProjects({ + const isAllPassed = await lintProjects({ projectReferences, template, workingDirectoryPath, cachedRepositoriesDirectoryPath, outputLogger, }); + + if (!isAllPassed) { + // eslint-disable-next-line require-atomic-updates + process.exitCode = 1; + } } /** @@ -226,18 +231,22 @@ async function lintProjects({ projectLintResultPromiseOutcomes.filter(isPromiseRejectedResult); outputLogger.logToStdout(''); + let isAllPassed = true; fulfilledProjectLintResultPromiseOutcomes .sort((a, b) => { return a.value.projectName.localeCompare(b.value.projectName); }) .forEach((fulfilledProjectLintResultPromiseOutcome, index) => { - reportProjectLintResult({ + const { numberOfFailing } = reportProjectLintResult({ projectLintResult: fulfilledProjectLintResultPromiseOutcome.value, outputLogger, }); if (index < fulfilledProjectLintResultPromiseOutcomes.length - 1) { outputLogger.logToStdout('\n'); } + if (numberOfFailing > 0) { + isAllPassed = false; + } }); outputLogger.logToStdout(''); @@ -246,4 +255,6 @@ async function lintProjects({ outputLogger.logToStderr(rejectedProjectLintResultPromiseOutcome.reason); }, ); + + return isAllPassed && rejectedProjectLintResultPromiseOutcomes.length === 0; } diff --git a/src/report-project-lint-result.ts b/src/report-project-lint-result.ts index ab190b9..2e69bc2 100644 --- a/src/report-project-lint-result.ts +++ b/src/report-project-lint-result.ts @@ -15,6 +15,7 @@ const log = createModuleLogger(projectLogger, 'fetch-or-populate-file-cache'); * @param args - The arguments to this function. * @param args.projectLintResult - The data collected from the lint execution. * @param args.outputLogger - Writable streams for output messages. + * @returns Passing and Failing numbers. */ export function reportProjectLintResult({ projectLintResult, @@ -62,6 +63,8 @@ export function reportProjectLintResult({ chalk.bold('Elapsed time:'), projectLintResult.elapsedTimeIncludingLinting, ); + + return { numberOfPassing, numberOfFailing }; } /** diff --git a/yarn.lock b/yarn.lock index 9e94f88..dcab767 100644 --- a/yarn.lock +++ b/yarn.lock @@ -985,9 +985,9 @@ __metadata: languageName: node linkType: hard -"@metamask/module-lint@workspace:.": +"@metamask/module-lint-fork@workspace:.": version: 0.0.0-use.local - resolution: "@metamask/module-lint@workspace:." + resolution: "@metamask/module-lint-fork@workspace:." dependencies: "@lavamoat/allow-scripts": ^2.3.1 "@lavamoat/preinstall-always-fail": ^1.0.0 @@ -1032,7 +1032,7 @@ __metadata: typescript: ~4.8.4 yargs: ^17.7.2 bin: - module-lint: ./dist/cli.js + module-lint-fork: ./dist/cli.js languageName: unknown linkType: soft From e787368c0a4944c0cbc77abd0ad47f76211c4d47 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Fri, 29 Mar 2024 12:26:38 +0000 Subject: [PATCH 09/15] module lint result post to slack channel --- .github/workflows/module-lint.yml | 45 +++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 51870dc..507f267 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -2,6 +2,25 @@ name: Module Lint on: workflow_call: + secrets: + slack-webhook-url: + description: 'Slack Webhook URL' + required: false + icon-url: + description: 'Url to the avatar used for the bot in Slack' + required: false + default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' + username: + description: 'The name of the bot as it appears on Slack' + required: false + default: 'MetaMask bot' + subteam: + description: 'Use this if you want to ping a subteam of individuals on Slack using @' + required: false + channel: + description: 'The Slack channel to post in' + required: false + default: 'temp-test-module-lint' jobs: prepare: @@ -45,3 +64,29 @@ jobs: echo "Working tree dirty at end of job" exit 1 fi + - id: final-text + shell: bash + if: secrets.slack-webhook-url != '' + run: | + DEFAULT_TEXT="" + SUBTEAM_TEXT="${{ secrets.subteam }}" + FINAL_TEXT="$DEFAULT_TEXT" + if [[ ! "$SUBTEAM_TEXT" == "" ]]; then + FINAL_TEXT=" $DEFAULT_TEXT" + fi + echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT" + - name: Post to a Slack channel + id: slack + if: secrets.slack-webhook-url != '' + uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 + with: + payload: | + { + "text": "${{ steps.final-text.outputs.FINAL_TEXT }}", + "icon_url": "${{ secrets.icon-url }}", + "username": "${{ secrets.username }}", + "channel": "#${{ secrets.channel }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK From c97db9a77e2accd078b19a46b5ab7f02434c381f Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 14:58:04 +0100 Subject: [PATCH 10/15] post to a slack channel --- .github/workflows/main.yml | 2 ++ .github/workflows/module-lint.yml | 42 +++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index da46a6e..ccf8829 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,6 +26,8 @@ jobs: module-lint: name: Module Lint uses: ./.github/workflows/module-lint.yml + secrets: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} all-jobs-completed: name: All jobs completed diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 507f267..e76b0ff 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -3,25 +3,23 @@ name: Module Lint on: workflow_call: secrets: - slack-webhook-url: - description: 'Slack Webhook URL' - required: false - icon-url: - description: 'Url to the avatar used for the bot in Slack' - required: false - default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' - username: - description: 'The name of the bot as it appears on Slack' - required: false - default: 'MetaMask bot' - subteam: - description: 'Use this if you want to ping a subteam of individuals on Slack using @' - required: false - channel: - description: 'The Slack channel to post in' - required: false - default: 'temp-test-module-lint' - + SLACK_WEBHOOK_URL: + required: true + icon-url: + description: 'Url to the avatar used for the bot in Slack' + required: false + default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' + username: + description: 'The name of the bot as it appears on Slack' + required: false + default: 'MetaMask bot' + subteam: + description: 'Use this if you want to ping a subteam of individuals on Slack using @' + required: false + channel: + description: 'The Slack channel to post in' + required: false + default: 'temp-test-module-lint' jobs: prepare: name: Prepare @@ -66,7 +64,7 @@ jobs: fi - id: final-text shell: bash - if: secrets.slack-webhook-url != '' + if: secrets.SLACK_WEBHOOK_URL != '' run: | DEFAULT_TEXT="" SUBTEAM_TEXT="${{ secrets.subteam }}" @@ -77,7 +75,7 @@ jobs: echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT" - name: Post to a Slack channel id: slack - if: secrets.slack-webhook-url != '' + if: secrets.SLACK_WEBHOOK_URL != '' uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 with: payload: | @@ -88,5 +86,5 @@ jobs: "channel": "#${{ secrets.channel }}" } env: - SLACK_WEBHOOK_URL: ${{ secrets.slack-webhook-url }} + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK From 075ddd68ff552d528115c5643f0db9a30a854709 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 15:28:17 +0100 Subject: [PATCH 11/15] post to a slack channel --- .github/workflows/module-lint.yml | 32 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index e76b0ff..b168b22 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -3,23 +3,21 @@ name: Module Lint on: workflow_call: secrets: - SLACK_WEBHOOK_URL: - required: true - icon-url: - description: 'Url to the avatar used for the bot in Slack' - required: false - default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' - username: - description: 'The name of the bot as it appears on Slack' - required: false - default: 'MetaMask bot' - subteam: - description: 'Use this if you want to ping a subteam of individuals on Slack using @' - required: false - channel: - description: 'The Slack channel to post in' - required: false - default: 'temp-test-module-lint' + icon-url: + description: 'Url to the avatar used for the bot in Slack' + required: false + default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' + username: + description: 'The name of the bot as it appears on Slack' + required: false + default: 'MetaMask bot' + subteam: + description: 'Use this if you want to ping a subteam of individuals on Slack using @' + required: false + channel: + description: 'The Slack channel to post in' + required: false + default: 'temp-test-module-lint' jobs: prepare: name: Prepare From 03ec89baf32d66eab481bd2bd6086bc633979940 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 15:34:52 +0100 Subject: [PATCH 12/15] revert post to a slack channel --- .github/workflows/module-lint.yml | 44 ++----------------------------- 1 file changed, 2 insertions(+), 42 deletions(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index b168b22..00b8ae5 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -2,22 +2,7 @@ name: Module Lint on: workflow_call: - secrets: - icon-url: - description: 'Url to the avatar used for the bot in Slack' - required: false - default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' - username: - description: 'The name of the bot as it appears on Slack' - required: false - default: 'MetaMask bot' - subteam: - description: 'Use this if you want to ping a subteam of individuals on Slack using @' - required: false - channel: - description: 'The Slack channel to post in' - required: false - default: 'temp-test-module-lint' + jobs: prepare: name: Prepare @@ -60,29 +45,4 @@ jobs: echo "Working tree dirty at end of job" exit 1 fi - - id: final-text - shell: bash - if: secrets.SLACK_WEBHOOK_URL != '' - run: | - DEFAULT_TEXT="" - SUBTEAM_TEXT="${{ secrets.subteam }}" - FINAL_TEXT="$DEFAULT_TEXT" - if [[ ! "$SUBTEAM_TEXT" == "" ]]; then - FINAL_TEXT=" $DEFAULT_TEXT" - fi - echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT" - - name: Post to a Slack channel - id: slack - if: secrets.SLACK_WEBHOOK_URL != '' - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - with: - payload: | - { - "text": "${{ steps.final-text.outputs.FINAL_TEXT }}", - "icon_url": "${{ secrets.icon-url }}", - "username": "${{ secrets.username }}", - "channel": "#${{ secrets.channel }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + From 648862563ed04a677478f5c6d0f3aa3d1b416e35 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 15:41:22 +0100 Subject: [PATCH 13/15] post to a slack channel --- .github/workflows/main.yml | 2 +- .github/workflows/module-lint.yml | 44 +++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ccf8829..5dffeaa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Main on: push: - branches: [main] + branches: [auto-module-lint] pull_request: jobs: diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 00b8ae5..b168b22 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -2,7 +2,22 @@ name: Module Lint on: workflow_call: - + secrets: + icon-url: + description: 'Url to the avatar used for the bot in Slack' + required: false + default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' + username: + description: 'The name of the bot as it appears on Slack' + required: false + default: 'MetaMask bot' + subteam: + description: 'Use this if you want to ping a subteam of individuals on Slack using @' + required: false + channel: + description: 'The Slack channel to post in' + required: false + default: 'temp-test-module-lint' jobs: prepare: name: Prepare @@ -45,4 +60,29 @@ jobs: echo "Working tree dirty at end of job" exit 1 fi - + - id: final-text + shell: bash + if: secrets.SLACK_WEBHOOK_URL != '' + run: | + DEFAULT_TEXT="" + SUBTEAM_TEXT="${{ secrets.subteam }}" + FINAL_TEXT="$DEFAULT_TEXT" + if [[ ! "$SUBTEAM_TEXT" == "" ]]; then + FINAL_TEXT=" $DEFAULT_TEXT" + fi + echo "FINAL_TEXT=$FINAL_TEXT" >> "$GITHUB_OUTPUT" + - name: Post to a Slack channel + id: slack + if: secrets.SLACK_WEBHOOK_URL != '' + uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 + with: + payload: | + { + "text": "${{ steps.final-text.outputs.FINAL_TEXT }}", + "icon_url": "${{ secrets.icon-url }}", + "username": "${{ secrets.username }}", + "channel": "#${{ secrets.channel }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK From 087de29a5a7fb80a63bf5c9c15641435f1357c8d Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 15:53:35 +0100 Subject: [PATCH 14/15] post to a slack channel --- .github/workflows/main.yml | 2 +- .github/workflows/module-lint.yml | 17 +---------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5dffeaa..ccf8829 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,7 +2,7 @@ name: Main on: push: - branches: [auto-module-lint] + branches: [main] pull_request: jobs: diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index b168b22..8f1cd68 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -2,22 +2,7 @@ name: Module Lint on: workflow_call: - secrets: - icon-url: - description: 'Url to the avatar used for the bot in Slack' - required: false - default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' - username: - description: 'The name of the bot as it appears on Slack' - required: false - default: 'MetaMask bot' - subteam: - description: 'Use this if you want to ping a subteam of individuals on Slack using @' - required: false - channel: - description: 'The Slack channel to post in' - required: false - default: 'temp-test-module-lint' + jobs: prepare: name: Prepare From fbb7cfe7eb7c646f4abbc414072b04fadc7b3e06 Mon Sep 17 00:00:00 2001 From: Kanthesha Devaramane Date: Wed, 10 Apr 2024 16:20:34 +0100 Subject: [PATCH 15/15] slack secrets --- .github/workflows/module-lint.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/module-lint.yml b/.github/workflows/module-lint.yml index 8f1cd68..b168b22 100644 --- a/.github/workflows/module-lint.yml +++ b/.github/workflows/module-lint.yml @@ -2,7 +2,22 @@ name: Module Lint on: workflow_call: - + secrets: + icon-url: + description: 'Url to the avatar used for the bot in Slack' + required: false + default: 'https://raw.githubusercontent.com/MetaMask/action-npm-publish/main/robo.png' + username: + description: 'The name of the bot as it appears on Slack' + required: false + default: 'MetaMask bot' + subteam: + description: 'Use this if you want to ping a subteam of individuals on Slack using @' + required: false + channel: + description: 'The Slack channel to post in' + required: false + default: 'temp-test-module-lint' jobs: prepare: name: Prepare