diff --git a/.github/workflows/validation.yml b/.github/workflows/validation.yml index 86b77c43..0a68a483 100644 --- a/.github/workflows/validation.yml +++ b/.github/workflows/validation.yml @@ -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 diff --git a/tests/domains.test.js b/tests/domains.test.js index 8cb68033..dfccdcf3 100644 --- a/tests/domains.test.js +++ b/tests/domains.test.js @@ -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 diff --git a/tests/json.test.js b/tests/json.test.js index f1bd162c..6bca94e5 100644 --- a/tests/json.test.js +++ b/tests/json.test.js @@ -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`); diff --git a/tests/proxy.test.js b/tests/proxy.test.js index b6b4396f..771a3225 100644 --- a/tests/proxy.test.js +++ b/tests/proxy.test.js @@ -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) {