From ab96bb23e4abde6761f8500fa656d4315a745045 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 30 Jan 2024 15:25:57 +0000 Subject: [PATCH 1/2] chore/validate-apps --- .github/workflows/validate_apps.yml | 21 +++++++++++++++++++++ validate-apps.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .github/workflows/validate_apps.yml create mode 100755 validate-apps.sh diff --git a/.github/workflows/validate_apps.yml b/.github/workflows/validate_apps.yml new file mode 100644 index 0000000..b29675b --- /dev/null +++ b/.github/workflows/validate_apps.yml @@ -0,0 +1,21 @@ +name: Validate apps + +on: + workflow_dispatch: + +jobs: + validate-apps: + runs-on: ubuntu-latest + + steps: + - name: install dependencies + run: | + sudo apt-get update + sudo apt-get install jq + + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run script + run: | + ./validate-apps.sh diff --git a/validate-apps.sh b/validate-apps.sh new file mode 100755 index 0000000..5e973fd --- /dev/null +++ b/validate-apps.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Function to perform HTTP GET request +http_get() { + local url=$1 + local response=$(curl -s -o /dev/null -w "%{http_code}" "$url") + echo "$response" +} + +# Find all manifest.json files recursively +manifest_files=$(find . -name "manifest.json") + +# Loop through each manifest file +for file in $manifest_files; do + # Extract href values from manifest.json + hrefs=$(jq -r '.href' "$file") + + # Loop through each href + for href in $hrefs; do + # Perform HTTP GET request + status_code=$(http_get "$href") + + # Check if status code is not 200 + if [[ $status_code -ge "400" ]]; then + echo "HTTP $status_code : $href" + fi + done +done From 43fe56812071e19b2e7e475e8142de7b334bbd10 Mon Sep 17 00:00:00 2001 From: clayton neal Date: Tue, 30 Jan 2024 15:52:14 +0000 Subject: [PATCH 2/2] code review --- .github/CODEOWNERS | 1 + .github/workflows/validate_apps.yml | 34 ++++++++++++++++------------- scripts/validate.ts | 1 + validate-apps.sh | 28 ------------------------ 4 files changed, 21 insertions(+), 43 deletions(-) create mode 100644 .github/CODEOWNERS delete mode 100755 validate-apps.sh diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..bf96198 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @vechain/public-repos \ No newline at end of file diff --git a/.github/workflows/validate_apps.yml b/.github/workflows/validate_apps.yml index b29675b..86a9410 100644 --- a/.github/workflows/validate_apps.yml +++ b/.github/workflows/validate_apps.yml @@ -1,21 +1,25 @@ -name: Validate apps - +name: Validate Links on: - workflow_dispatch: + workflow_dispatch: jobs: - validate-apps: - runs-on: ubuntu-latest + validate-links: + runs-on: ubuntu-latest - steps: - - name: install dependencies - run: | - sudo apt-get update - sudo apt-get install jq + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Checkout repository - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: '16' + cache: 'npm' - - name: Run script - run: | - ./validate-apps.sh + - name: Install Dependencies + run: npm ci + + - name: Run validation + run: npm run validate:links + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/validate.ts b/scripts/validate.ts index 8590343..00bedcb 100644 --- a/scripts/validate.ts +++ b/scripts/validate.ts @@ -107,6 +107,7 @@ const checkLink = async (appDir: string) => { const link = manifest.href try { + console.log(`checking ${link}`) await axios.get(link) } catch (e) { throw new ValidationError(`${link} is not reachable`) diff --git a/validate-apps.sh b/validate-apps.sh deleted file mode 100755 index 5e973fd..0000000 --- a/validate-apps.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Function to perform HTTP GET request -http_get() { - local url=$1 - local response=$(curl -s -o /dev/null -w "%{http_code}" "$url") - echo "$response" -} - -# Find all manifest.json files recursively -manifest_files=$(find . -name "manifest.json") - -# Loop through each manifest file -for file in $manifest_files; do - # Extract href values from manifest.json - hrefs=$(jq -r '.href' "$file") - - # Loop through each href - for href in $hrefs; do - # Perform HTTP GET request - status_code=$(http_get "$href") - - # Check if status code is not 200 - if [[ $status_code -ge "400" ]]; then - echo "HTTP $status_code : $href" - fi - done -done