Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/attributions bot #24897

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
80f4d6a
feat: add new attributions workflow
cryptodev-2s May 6, 2024
4b82bba
fix: add missing runs-on on update-attributions gh action
cryptodev-2s May 6, 2024
4f86499
fix: update readme
cryptodev-2s May 7, 2024
ae202cd
feat: add attribution check gh action
cryptodev-2s May 7, 2024
2146983
fix: update check attribution action trigger
cryptodev-2s May 7, 2024
6fac431
fix: attributions check gh action
cryptodev-2s May 7, 2024
afec127
fix: check attribution gh action remove useless pr checkout by number
cryptodev-2s May 7, 2024
aba129c
fix: update attribution file
cryptodev-2s May 7, 2024
8dc080f
fix: remove fork check on attributions update
cryptodev-2s May 7, 2024
3c8d14e
fix: attribution script
cryptodev-2s May 9, 2024
256fb51
fix: restore .gitignore
cryptodev-2s May 9, 2024
56f6d84
Update LavaMoat policies
metamaskbot May 9, 2024
ccc3bd6
fix: run yarn dedupe
cryptodev-2s May 9, 2024
8a6ee29
Update LavaMoat policies
metamaskbot May 9, 2024
ee20d14
fix: update attributions
cryptodev-2s May 9, 2024
2ecc8f0
fix: attribution script to use node instead of python
cryptodev-2s May 9, 2024
91051c2
fix: update attributions
cryptodev-2s May 14, 2024
469efeb
fix: update attribution
cryptodev-2s May 16, 2024
d3373d1
Extract yarnrc override script
cryptodev-2s May 20, 2024
9cd958a
Merge remote-tracking branch 'origin/develop' into fix/attributions
cryptodev-2s May 20, 2024
2d31777
Update attributions
cryptodev-2s May 20, 2024
49960b2
Merge remote-tracking branch 'origin/develop' into fix/attributions
cryptodev-2s May 23, 2024
1005376
fix: attributions
cryptodev-2s May 23, 2024
f05f31d
Merge branch 'develop' into fix/attributions
cryptodev-2s May 23, 2024
cf29c2c
fix: refactor check attribution action
cryptodev-2s May 29, 2024
41493b4
Merge remote-tracking branch 'origin/develop' into fix/attributions
cryptodev-2s May 29, 2024
7de46d4
fix: update attribution file
cryptodev-2s May 29, 2024
3a8b245
fix: attribution typo
cryptodev-2s May 29, 2024
4aeb511
fix: attribution typo
cryptodev-2s May 29, 2024
b2ecf5a
fix: attribution check
cryptodev-2s May 29, 2024
5a61bba
Merge branch 'develop' into fix/attributions
cryptodev-2s May 29, 2024
d131569
Update LavaMoat policies
metamaskbot May 29, 2024
db18397
Merge branch 'develop' into fix/attributions
cryptodev-2s May 29, 2024
d547f04
fix: use attributions instead of attribution
cryptodev-2s May 29, 2024
3c5b2b7
Merge remote-tracking branch 'origin/develop' into fix/attributions
cryptodev-2s May 29, 2024
6a72bdc
fix: restore policies
cryptodev-2s May 29, 2024
5c8c582
fix: restore lavamoat
cryptodev-2s May 29, 2024
7667a4f
fix: restore package.json and yarn lockfile
cryptodev-2s May 29, 2024
c60ee1a
Merge branch 'develop' into fix/attributions
cryptodev-2s May 30, 2024
ab1d5ce
fix: attributions
cryptodev-2s May 30, 2024
3911727
fix: attributions script comments
cryptodev-2s May 30, 2024
7e2655c
test: incomplete attibution
cryptodev-2s May 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/check-attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Generate and Validate Attributions

on:
pull_request:
branches:
- develop
types:
- opened
- synchronize

jobs:
generate-and-validate-attributions:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies from cache
run: yarn --immutable
- name: Generate Attributions
run: yarn generate:attributions
- name: Check attributions changes
run: yarn test:attributions-check
166 changes: 166 additions & 0 deletions .github/workflows/update-attributions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Update Attibutions

on:
issue_comment:
types: created

jobs:
react-to-comment:
name: React to the comment
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot update-attributions') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: React to the comment
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/${REPO}/issues/comments/${COMMENT_ID}/reactions" \
-f content='+1'
env:
COMMENT_ID: ${{ github.event.comment.id }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}

prepare:
name: Prepare dependencies
runs-on: ubuntu-latest
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '@metamaskbot update-attributions') }}
outputs:
COMMIT_SHA: ${{ steps.commit-sha.outputs.COMMIT_SHA }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install Yarn dependencies
run: yarn --immutable
- name: Get commit SHA
id: commit-sha
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"

update-attributions:
name: Update Attributions
runs-on: ubuntu-latest
needs:
- prepare
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Install dependencies from cache
run: yarn --immutable --immutable-cache
- name: Generate Atributions
run: yarn generate:attributions
- name: Cache attributions file
uses: actions/cache/save@v3
with:
path: attribution.txt
key: cache-build-${{ needs.prepare.outputs.COMMIT_SHA }}

commit-updated-attributions:
name: Commit the updated Attributions
runs-on: ubuntu-latest
needs:
- prepare
- update-attributions
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Use PAT to ensure that the commit later can trigger status check workflows
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout pull request
run: gh pr checkout "${PR_NUMBER}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
- name: Get commit SHA
id: commit-sha
run: echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- name: Restore attributions file
uses: actions/cache/restore@v3
with:
path: attribution.txt
key: cache-build-${{ needs.prepare.outputs.COMMIT_SHA }}
fail-on-cache-miss: true
- name: Check whether there are attributions changes
id: attributions-changes
run: |
if git diff --exit-code
then
echo "HAS_CHANGES=false" >> "$GITHUB_OUTPUT"
else
echo "HAS_CHANGES=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit the updated attributions
if: steps.attributions-changes.outputs.HAS_CHANGES == 'true'
run: |
git config --global user.name 'MetaMask Bot'
git config --global user.email '[email protected]'
git commit -am "Update Attributions"
git push
- name: Post comment
run: |
if [[ $HAS_CHANGES == 'true' ]]
then
gh pr comment "${PR_NUMBER}" --body 'Attributions updated'
else
gh pr comment "${PR_NUMBER}" --body 'No attributions changes'
fi
env:
HAS_CHANGES: ${{ steps.attributions-changes.outputs.HAS_CHANGES }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}

check-status:
name: Check whether the attributions update succeeded
runs-on: ubuntu-latest
needs:
- commit-updated-attributions
outputs:
PASSED: ${{ steps.set-output.outputs.PASSED }}
steps:
- name: Set PASSED output
id: set-output
run: echo "PASSED=true" >> "$GITHUB_OUTPUT"

failure-comment:
name: Comment about the attributions update failure
runs-on: ubuntu-latest
needs:
- check-status
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Post comment if the update failed
run: |
passed="${{ needs.check-status.outputs.PASSED }}"
if [[ $passed != "true" ]]; then
gh pr comment "${PR_NUMBER}" --body "Attributions update failed. You can [review the logs or retry the attributions update here](${ACTION_RUN_URL})"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.issue.number }}
ACTION_RUN_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ test-results/
!.yarn/releases
!.yarn/sdks
!.yarn/versions
**/.yarn/*

# MMI Playwright
public/playwright
Expand Down
2 changes: 1 addition & 1 deletion .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module.exports = {
name: "@yarnpkg/plugin-allow-scripts",
factory: function (require) {
var plugin=(()=>{var a=Object.create,l=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var u=e=>l(e,"__esModule",{value:!0});var f=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var g=(e,o)=>{for(var r in o)l(e,r,{get:o[r],enumerable:!0})},m=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!c.call(e,t)&&t!=="default"&&l(e,t,{get:()=>o[t],enumerable:!(r=i(o,t))||r.enumerable});return e},x=e=>m(u(l(e!=null?a(p(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k={};g(k,{default:()=>d});var n=x(f("@yarnpkg/shell")),y={hooks:{afterAllInstalled:async()=>{let e=await(0,n.execute)("yarn run allow-scripts");e!==0&&process.exit(e)}}},d=y;return k;})();
var plugin=(()=>{var a=Object.create,l=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty;var u=e=>l(e,"__esModule",{value:!0});var f=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var g=(e,o)=>{for(var r in o)l(e,r,{get:o[r],enumerable:!0})},m=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of s(o))!c.call(e,t)&&t!=="default"&&l(e,t,{get:()=>o[t],enumerable:!(r=i(o,t))||r.enumerable});return e},x=e=>m(u(l(e!=null?a(p(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k={};g(k,{default:()=>d});var n=x(f("@yarnpkg/shell")),y={hooks:{afterAllInstalled:async()=>{let e=await(0,n.execute)("yarn exec allow-scripts");e!==0&&process.exit(e)}}},d=y;return k;})();
return plugin;
}
};
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ Whenever you change dependencies (adding, removing, or updating, either in `pack
- `rm -rf node_modules/ && yarn && yarn lavamoat:auto`
- Keep in mind that any kind of dynamic import or dynamic use of globals may elude LavaMoat's static analysis.
Refer to the LavaMoat documentation or ask for help if you run into any issues.
- The Attributions file
- If you are a MetaMask team member and your PR is on a repository branch, you can use the bot command `@metamaskbot update-attributions` to ask the MetaMask bot to automatically update the attributions file for you.
- Manual update: run `yarn generate:attributions`.

## Architecture

Expand Down
Loading
Loading