Merge pull request #1787 from open-domains/Kyro3400-validation-stuff

Validation Edits (CAN BE MERGED NOW)
This commit is contained in:
andrewstech authored and GitHub committed 2024-11-25 21:19:17 +00:00
commit 61244bf32f
4 files changed
+14 -43

No files matched your search

+11 -13
View File
@@ -1,7 +1,7 @@
name: Validation
on:
pull_request:
pull_request_target:
push:
branches: [main]
@@ -17,13 +17,12 @@ on:
concurrency:
group: ${{ github.ref }}-validation
cancel-in-progress: true
jobs:
dns:
name: DNS
if: "!contains(github.event.head_commit.message, '[skip-ci]')"
runs-on: ubuntu-latest
steps:
name: DNS
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
@@ -38,15 +37,15 @@ jobs:
id: dns_check
uses: is-a-dev/dnscontrol-action@main
with:
args: check
config_file: "dnsconfig.js"
args: check
config_file: "dnsconfig.js"
- name: Add Validated DNS Label
if: ${{ steps.dns_check.outcome == 'success' }}
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "Validated DNS"
github_token: ${{ steps.create_token.outputs.token }}
labels: "Validated DNS"
github_token: ${{ steps.create_token.outputs.token }}
- name: Remove Invalid DNS Label
if: ${{ steps.dns_check.outcome == 'success' }}
uses: actions-ecosystem/action-remove-labels@v1
@@ -60,13 +59,12 @@ jobs:
with:
labels: "Invalid DNS"
github_token: ${{ steps.create_token.outputs.token }}
- name: Remove Validated DNS Label
if: ${{ failure() }}
uses: actions-ecosystem/action-remove-labels@v1
with:
labels: "Validated DNS"
github_token: ${{ steps.create_token.outputs.token }}
labels: "Validated DNS"
github_token: ${{ steps.create_token.outputs.token }}
json:
name: JSON
+2 -2
View File
@@ -13,7 +13,7 @@ t("Nested subdomains should not exist without a parent subdomain", (t) => {
return; // Skip directories
}
const subdomain = file.replace(".json", "");
const subdomain = file.replace(/\.json$/, "");
if (subdomain.split(".").length > 1) {
// Get parent domain by removing the last part (subdomain) from the full subdomain
@@ -38,7 +38,7 @@ t("Nested subdomains should not exist if the parent subdomain has NS records", (
return; // Skip directories
}
const subdomain = file.replace(".json", "");
const subdomain = file.replace(/\.json$/, "");
if (subdomain.split(".").length > 1) {
// Get parent domain by removing the last part (subdomain) from the full subdomain
-27
View File
@@ -41,32 +41,6 @@ function validateOptionalFields(t, obj, optionalFields, file) {
});
}
t("All files should be valid JSON", (t) => {
files.forEach((file) => {
t.notThrows(() => fs.readJsonSync(path.join(domainsPath, file)), `${file}: Invalid JSON file`);
});
});
t("All files should have valid file names", (t) => {
files.forEach((file) => {
t.true(file.endsWith(".json"), `${file}: File does not have .json extension`);
// Check for any unwanted domain in file names
t.false(Domains.some(domain => file.endsWith(domain + ".json")), `${file}: File name should not contain restricted domain extensions`);
t.true(file === file.toLowerCase(), `${file}: File name should be lowercase`);
// Ignore root domain
if (!rootDomainFiles.includes(file)) {
t.regex(
file.replace(/\.json$/, ""),
hostnameRegex,
`${file}: FQDN must be 1-253 characters, use letters, numbers, dots, or hyphens, and not start or end with a hyphen.`
);
}
});
});
t("All files should have the required fields", (t) => {
const files = fs.readdirSync(domainsPath).filter(file => {
const filePath = path.join(domainsPath, file);
@@ -76,7 +50,6 @@ t("All files should have the required fields", (t) => {
const data = fs.readJsonSync(path.join(domainsPath, file));
validateRequiredFields(t, data, requiredFields, file);
//validateRequiredFields(t, data.owner, requiredFields, file);
if (!data.reserved) {
t.true(Object.keys(data.record).length > 0, `${file}: No record types found`);
+1 -1
View File
@@ -2,7 +2,7 @@ const t = require("ava");
const fs = require("fs-extra");
const path = require("path");
const requiredRecordsToProxy = ["A", "AAAA", "CAA", "CNAME", "MX", "NS", "SPF", "SRV"];
const requiredRecordsToProxy = ["A", "AAAA", "CAA", "CNAME", "MX", "NS", "SRV"];
function validateProxiedRecords(t, data, file) {
if (data.proxied) {