mirror of
https://github.com/tiennm99/is-a-dev.git
synced 2026-08-21 08:26:08 +00:00
add basic pr tests
This commit is contained in:
@@ -36,6 +36,15 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Get Modified JSON Files
|
||||
id: modified_files
|
||||
run: |
|
||||
MODIFIED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^domains/.*\.json$' | sed 's|.*/||' | tr '\n' ',' | sed 's|,$||')
|
||||
echo "MODIFIED_FILES=${MODIFIED_FILES}" >> $GITHUB_ENV
|
||||
|
||||
- run: npm install
|
||||
|
||||
- run: npm test
|
||||
env:
|
||||
PULL_REQUEST: ${{ github.event.pull_request.number || false }} # false if not a PR
|
||||
MODIFIED_FILES: ${{ env.MODIFIED_FILES }}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
if (!process.env.PULL_REQUEST) return;
|
||||
|
||||
const t = require("ava");
|
||||
const fs = require("fs-extra");
|
||||
const path = require("path");
|
||||
|
||||
const PR_AUTHOR = process.env.PR_AUTHOR;
|
||||
const MODIFIED_FILES = process.env.MODIFIED_FILES.split(",");
|
||||
|
||||
const domainsPath = path.resolve("domains");
|
||||
|
||||
const admins = require("../util/administrators.json");
|
||||
|
||||
t("Modified JSON files must be owned by the PR author", (t) => {
|
||||
MODIFIED_FILES.forEach((file) => {
|
||||
const domain = fs.readJsonSync(path.join(domainsPath, file));
|
||||
|
||||
t.true(
|
||||
domain.owner.username === PR_AUTHOR || admins.includes(PR_AUTHOR),
|
||||
`${file}: Owner should be ${PR_AUTHOR} but is ${domain.owner}`
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
[
|
||||
"wdhdev",
|
||||
"DEV-DIBSTER"
|
||||
]
|
||||
@@ -8,7 +8,9 @@
|
||||
"api",
|
||||
"auth",
|
||||
"authentication",
|
||||
"authorisation",
|
||||
"authorise",
|
||||
"authorization",
|
||||
"authorize",
|
||||
"aux",
|
||||
"billing",
|
||||
@@ -17,6 +19,7 @@
|
||||
"cart",
|
||||
"catalog",
|
||||
"checkout",
|
||||
"co",
|
||||
"com",
|
||||
"com[1-9]",
|
||||
"con",
|
||||
@@ -74,7 +77,6 @@
|
||||
"payments",
|
||||
"portal",
|
||||
"postmaster",
|
||||
"prn",
|
||||
"recovery",
|
||||
"redirect",
|
||||
"registrar",
|
||||
|
||||
Reference in New Issue
Block a user