Skip to content

Commit

Permalink
Merge branch 'strapi:master' into fix/up-middleware-config-override
Browse files Browse the repository at this point in the history
  • Loading branch information
WalkingPizza committed Mar 8, 2022
2 parents 3ed05d3 + 7b4d0e0 commit bf87b56
Show file tree
Hide file tree
Showing 381 changed files with 13,569 additions and 5,277 deletions.
1 change: 1 addition & 0 deletions .github/actions/check-pr-status/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!dist
35 changes: 35 additions & 0 deletions .github/actions/check-pr-status/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# PR checker for status

This action checks a PR labels, milestone and status to validate it is ready for merging into master.

> ❗️ When making changes to this code, make sure to run the build before committing. See [Development](#development) to know more.
## Conditions

1. The PR should not have the following labels:

- `flag: 💥 Breaking change`
- `flag: don't merge`

2. The PR should have one and only one `source: *` label.
3. The PR should have one and only one `issue-type: *` label.
4. The PR must have a milestone defined.

## Contributing

### Requirements

- The code is compatible with Node 14+

### Dependencies

- Run `yarn` to install the dependencies

### Development

In order for the action to run on github all the code needs to be bundled and committed because github actions do not manage dependencies for us. [Github reference documentation](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github).

### Commands

- `yarn build`: Build the code the must be committed
- `yarn watch`: Build in watch mode
102 changes: 102 additions & 0 deletions .github/actions/check-pr-status/__tests__/action.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const action = require('../index');

jest.mock('@actions/github');
jest.mock('@actions/core');

const github = require('@actions/github');
const core = require('@actions/core');

test.each(action.BLOCKING_LABELS)('Test blocking labels %s', async label => {
github.context = {
payload: {
pull_request: {
labels: [{ name: label }],
},
},
};

const setFailed = jest.spyOn(core, 'setFailed');

await action();

expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toContain(`The PR has been labelled with a blocking label`);

setFailed.mockRestore();
});

test('Test missing source label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'pr: enhancement' }],
},
},
};

const setFailed = jest.spyOn(core, 'setFailed');

await action();

expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'source:' label.`);

setFailed.mockRestore();
});

test('Test too many source label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'source: a' }, { name: 'source: b' }, { name: 'pr: enhancement' }],
},
},
};

const setFailed = jest.spyOn(core, 'setFailed');

await action();

expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'source:' label.`);

setFailed.mockRestore();
});

test('Test missing pr label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'source: core' }],
},
},
};

const setFailed = jest.spyOn(core, 'setFailed');

await action();

expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'pr:' label.`);

setFailed.mockRestore();
});

test('Test too many pr label', async () => {
github.context = {
payload: {
pull_request: {
labels: [{ name: 'pr: a' }, { name: 'pr: b' }, { name: 'source: core' }],
},
},
};

const setFailed = jest.spyOn(core, 'setFailed');

await action();

expect(setFailed).toHaveBeenCalled();
expect(setFailed.mock.calls[0][0]).toBe(`The PR must have one and only one 'pr:' label.`);

setFailed.mockRestore();
});
5 changes: 5 additions & 0 deletions .github/actions/check-pr-status/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: 'PR Checker'
description: 'Check PR status for mergeability'
runs:
using: 'node16'
main: 'dist/index.js'
13 changes: 13 additions & 0 deletions .github/actions/check-pr-status/dist/index.js

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions .github/actions/check-pr-status/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const core = require('@actions/core');
const github = require('@actions/github');

const BLOCKING_LABELS = [`flag: 💥 Breaking change`, `flag: don't merge`];

async function main() {
try {
const labels = github.context.payload.pull_request?.labels ?? [];

const blockingLabels = labels.filter(label => BLOCKING_LABELS.includes(label.name));

if (blockingLabels.length > 0) {
core.setFailed(
`The PR has been labelled with a blocking label (${blockingLabels
.map(label => label.name)
.join(', ')}).`
);

return;
}

const sourceLabelCount = labels.filter(label => label.name.startsWith('source: ')).length;
const issueLabelCount = labels.filter(label => label.name.startsWith('pr: ')).length;

if (sourceLabelCount !== 1) {
core.setFailed(`The PR must have one and only one 'source:' label.`);
}

if (issueLabelCount !== 1) {
core.setFailed(`The PR must have one and only one 'pr:' label.`);
}

// NOTE: to avoid manual work, this is commented until we can set the workflow to trigger on pull_request milestone changes.
// ref: https://github.community/t/feature-request-add-milestone-changes-as-activity-type-to-pull-request/16778/16
/*
const milestone = context.payload.pull_request?.milestone;
const hasMilestone = !!milestone;
if (!hasMilestone) {
core.setFailed(`The PR must have a milestone.`);
}
*/
} catch (error) {
core.setFailed(error.message);
}
}

main.BLOCKING_LABELS = BLOCKING_LABELS;

if (require.main === module) {
main();
} else {
module.exports = main;
}
16 changes: 16 additions & 0 deletions .github/actions/check-pr-status/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "check-pr-status",
"version": "4.1.2",
"main": "dist/index.js",
"license": "MIT",
"private": true,
"scripts": {
"build": "NODE_ENV=production ncc build index.js -o dist --minify",
"watch": "NODE_ENV=production ncc build index.js -w -o dist --minify"
},
"devDependencies": {
"@actions/core": "1.6.0",
"@actions/github": "5.0.0",
"@vercel/ncc": "0.33.3"
}
}
180 changes: 180 additions & 0 deletions .github/actions/check-pr-status/yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@actions/core@1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb"
integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==
dependencies:
"@actions/http-client" "^1.0.11"

"@actions/github@5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@actions/github/-/github-5.0.0.tgz#1754127976c50bd88b2e905f10d204d76d1472f8"
integrity sha512-QvE9eAAfEsS+yOOk0cylLBIO/d6WyWIOvsxxzdrPFaud39G6BOkUwScXZn1iBzQzHyu9SBkkLSWlohDWdsasAQ==
dependencies:
"@actions/http-client" "^1.0.11"
"@octokit/core" "^3.4.0"
"@octokit/plugin-paginate-rest" "^2.13.3"
"@octokit/plugin-rest-endpoint-methods" "^5.1.1"

"@actions/http-client@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
dependencies:
tunnel "0.0.6"

"@octokit/auth-token@^2.4.4":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36"
integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==
dependencies:
"@octokit/types" "^6.0.3"

"@octokit/core@^3.4.0":
version "3.5.1"
resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.5.1.tgz#8601ceeb1ec0e1b1b8217b960a413ed8e947809b"
integrity sha512-omncwpLVxMP+GLpLPgeGJBF6IWJFjXDS5flY5VbppePYX9XehevbDykRH9PdCdvqt9TS5AOTiDide7h0qrkHjw==
dependencies:
"@octokit/auth-token" "^2.4.4"
"@octokit/graphql" "^4.5.8"
"@octokit/request" "^5.6.0"
"@octokit/request-error" "^2.0.5"
"@octokit/types" "^6.0.3"
before-after-hook "^2.2.0"
universal-user-agent "^6.0.0"

"@octokit/endpoint@^6.0.1":
version "6.0.12"
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.12.tgz#3b4d47a4b0e79b1027fb8d75d4221928b2d05658"
integrity sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==
dependencies:
"@octokit/types" "^6.0.3"
is-plain-object "^5.0.0"
universal-user-agent "^6.0.0"

"@octokit/graphql@^4.5.8":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3"
integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==
dependencies:
"@octokit/request" "^5.6.0"
"@octokit/types" "^6.0.3"
universal-user-agent "^6.0.0"

"@octokit/openapi-types@^11.2.0":
version "11.2.0"
resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-11.2.0.tgz#b38d7fc3736d52a1e96b230c1ccd4a58a2f400a6"
integrity sha512-PBsVO+15KSlGmiI8QAzaqvsNlZlrDlyAJYcrXBCvVUxCp7VnXjkwPoFHgjEJXx3WF9BAwkA6nfCUA7i9sODzKA==

"@octokit/plugin-paginate-rest@^2.13.3":
version "2.17.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.17.0.tgz#32e9c7cab2a374421d3d0de239102287d791bce7"
integrity sha512-tzMbrbnam2Mt4AhuyCHvpRkS0oZ5MvwwcQPYGtMv4tUa5kkzG58SVB0fcsLulOZQeRnOgdkZWkRUiyBlh0Bkyw==
dependencies:
"@octokit/types" "^6.34.0"

"@octokit/plugin-rest-endpoint-methods@^5.1.1":
version "5.13.0"
resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.13.0.tgz#8c46109021a3412233f6f50d28786f8e552427ba"
integrity sha512-uJjMTkN1KaOIgNtUPMtIXDOjx6dGYysdIFhgA52x4xSadQCz3b/zJexvITDVpANnfKPW/+E0xkOvLntqMYpviA==
dependencies:
"@octokit/types" "^6.34.0"
deprecation "^2.3.1"

"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677"
integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==
dependencies:
"@octokit/types" "^6.0.3"
deprecation "^2.0.0"
once "^1.4.0"

"@octokit/request@^5.6.0":
version "5.6.3"
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0"
integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==
dependencies:
"@octokit/endpoint" "^6.0.1"
"@octokit/request-error" "^2.1.0"
"@octokit/types" "^6.16.1"
is-plain-object "^5.0.0"
node-fetch "^2.6.7"
universal-user-agent "^6.0.0"

"@octokit/types@^6.0.3", "@octokit/types@^6.16.1", "@octokit/types@^6.34.0":
version "6.34.0"
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.34.0.tgz#c6021333334d1ecfb5d370a8798162ddf1ae8218"
integrity sha512-s1zLBjWhdEI2zwaoSgyOFoKSl109CUcVBCc7biPJ3aAf6LGLU6szDvi31JPU7bxfla2lqfhjbbg/5DdFNxOwHw==
dependencies:
"@octokit/openapi-types" "^11.2.0"

"@vercel/ncc@0.33.1":
version "0.33.1"
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.33.1.tgz#b240080a3c1ded9446a30955a06a79851bb38f71"
integrity sha512-Mlsps/P0PLZwsCFtSol23FGqT3FhBGb4B1AuGQ52JTAtXhak+b0Fh/4T55r0/SVQPeRiX9pNItOEHwakGPmZYA==

before-after-hook@^2.2.0:
version "2.2.2"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e"
integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==

deprecation@^2.0.0, deprecation@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==

is-plain-object@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"
integrity sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==

node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
whatwg-url "^5.0.0"

once@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E=
dependencies:
wrappy "1"

tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=

tunnel@0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==

universal-user-agent@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee"
integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==

webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=

whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha1-lmRU6HZUYuN2RNNib2dCzotwll0=
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"

wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=

0 comments on commit bf87b56

Please sign in to comment.