Merge branch 'main' into patch-11

This commit is contained in:
William Harrison
2025-01-02 22:33:48 +11:00
committed by GitHub
2 changed files with 36 additions and 11 deletions
+7 -9
View File
@@ -35,6 +35,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: ${{ github.run_id }}
- uses: actions/checkout@v4
with:
repository: is-a-dev/register
path: register
- run: npm install
@@ -45,15 +52,6 @@ jobs:
with:
files: domains/*.json
- name: testing
run: |
ls
ls ../
echo ${{ steps.changed-files.outputs.all_changed_files }}
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
cat $file
done
- run: npm test
env:
EVENT: ${{ github.event_name }}
+29 -2
View File
@@ -10,6 +10,7 @@ for (let i = 0; i < MODIFIED_FILES.length; i++) {
}
const domainsPath = path.resolve("domains");
const headDomainsPath = path.resolve("../register/domains");
const admins = require("../util/administrators.json");
@@ -20,11 +21,37 @@ t("Modified JSON files must be owned by the PR author", (t) => {
}
MODIFIED_FILES.forEach((file) => {
const modifiedDomain = fs.readJsonSync(path.join(domainsPath, file));
let currentDomain = null;
try {
currentDomain = fs.readJsonSync(path.join(headDomainsPath, file));
} catch {
currentDomain = modifiedDomain;
}
t.true(
currentDomain.owner.username === PR_AUTHOR || admins.includes(PR_AUTHOR),
`${file}: Domain owner is ${domain.owner.username} but ${PR_AUTHOR} is the PR author`
);
});
});
t("New JSON files must be owned by the PR author", (t) => {
if(process.env.EVENT !== "pull_request") {
t.pass();
return;
}
const newFiles = fs.readdirSync(domainsPath).filter((file) => !fs.readdirSync(headDomainsPath).includes(file));
newFiles.forEach((file) => {
const domain = fs.readJsonSync(path.join(domainsPath, file));
t.true(
domain.owner.username === PR_AUTHOR || admins.includes(PR_AUTHOR),
`${file}: Owner is ${domain.owner.username} but ${PR_AUTHOR} is the PR author`
`${file}: Domain owner is ${domain.owner.username} but ${PR_AUTHOR} is the PR author`
);
});
});
})