From 91a37f7c1a86c143476c14c0930aa33919a81830 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 16:28:20 -0700 Subject: [PATCH 01/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 75 +++++++++++++------ 1 file changed, 51 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 6100fe2..7566390 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -10,44 +10,71 @@ on: pull_request: branches: [ main ] jobs: - build-and-publish: - if: secrets.PINATA_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null && secrets.ESTUARY_API_ENDPOINT != null && secrets.ESTUARY_API_TOKEN != null && secrets.NFT_API_ENDPOINT != null && secrets.NFT_API_TOKEN != null && secrets.WEB3_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null + checkout: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + + run-compliance-checks: + runs-on: ubuntu-latest + # if: secrets.PINATA_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null && secrets.ESTUARY_API_ENDPOINT != null && secrets.ESTUARY_API_TOKEN != null && secrets.NFT_API_ENDPOINT != null && secrets.NFT_API_TOKEN != null && secrets.WEB3_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null strategy: fail-fast: false matrix: service: [pinata, estuary, nft, web3] - include: - - service: pinata - endpoint: ${{ secrets.PINATA_API_ENDPOINT }} - token: ${{secrets.PINATA_API_TOKEN}} - - service: estuary - endpoint: ${{ secrets.ESTUARY_API_ENDPOINT }} - token: ${{secrets.ESTUARY_API_TOKEN}} - - service: nft - endpoint: ${{ secrets.NFT_API_ENDPOINT }} - token: ${{secrets.NFT_API_TOKEN}} - - service: web3 - endpoint: ${{ secrets.WEB3_API_ENDPOINT }} - token: ${{secrets.WEB3_API_TOKEN}} + # include: + # - service: pinata + # endpoint: ${{ secrets.PINATA_API_ENDPOINT }} + # token: ${{secrets.PINATA_API_TOKEN}} + # - service: estuary + # endpoint: ${{ secrets.ESTUARY_API_ENDPOINT }} + # token: ${{secrets.ESTUARY_API_TOKEN}} + # - service: nft + # endpoint: ${{ secrets.NFT_API_ENDPOINT }} + # token: ${{secrets.NFT_API_TOKEN}} + # - service: web3 + # endpoint: ${{ secrets.WEB3_API_ENDPOINT }} + # token: ${{secrets.WEB3_API_TOKEN}} concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. - runs-on: ubuntu-latest steps: - name: Checkout 🛎️ uses: actions/checkout@v3 - - name: Install dependencies - run: npm ci + # TODO: Migrate reports to use npx + - name: Generate report (Pinata) + if: ${{ matrix.service === 'pinata' }} + uses: ipfs/aegir/actions/cache-node-modules@master + run: npm dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} + + # TODO: Migrate reports to use npx + - name: Generate report (Estuary) + if: ${{ matrix.service === 'estuary' }} + uses: ipfs/aegir/actions/cache-node-modules@master + run: npm dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} - # Migrate reports to use npx - - name: Generate reports - run: npm dev-start -- -s ${{ secrets[matrix.endpoint] }} ${{ secrets[matrix.token] }} + # TODO: Migrate reports to use npx + - name: Generate report (NFT.storage) + if: ${{ matrix.service === 'nft' }} + uses: ipfs/aegir/actions/cache-node-modules@master + run: npm dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} - # Deploy to gh pages branch + # TODO: Migrate reports to use npx + - name: Generate report (web3.storage) + if: ${{ matrix.service === 'web3' }} + uses: ipfs/aegir/actions/cache-node-modules@master + run: npm dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} + # Deploy to gh pages branch + deploy: + if: success() + concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + runs-on: ubuntu-latest + steps: ## Cron jobs - name: Scheduled deployment - if: success() && (github.event.schedule != null || github.event.pusher != null) + if: github.event.schedule != null || github.event.pusher != null uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self @@ -57,7 +84,7 @@ jobs: ## PRs should push to branch other than primary `gh-pages` branch - name: Deployment for PR - if: success() && github.event.pull_request != null + if: github.event.pull_request != null uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self From b6543ac04e8b0031627694ca6452a332b9072f4e Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:21:18 -0700 Subject: [PATCH 02/33] Update build-and-publish-reports.yml --- .github/workflows/build-and-publish-reports.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 7566390..463e7e1 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -42,28 +42,25 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 + - uses: ipfs/aegir/actions/cache-node-modules@master # TODO: Migrate reports to use npx - name: Generate report (Pinata) if: ${{ matrix.service === 'pinata' }} - uses: ipfs/aegir/actions/cache-node-modules@master run: npm dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (Estuary) if: ${{ matrix.service === 'estuary' }} - uses: ipfs/aegir/actions/cache-node-modules@master run: npm dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (NFT.storage) if: ${{ matrix.service === 'nft' }} - uses: ipfs/aegir/actions/cache-node-modules@master run: npm dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (web3.storage) if: ${{ matrix.service === 'web3' }} - uses: ipfs/aegir/actions/cache-node-modules@master run: npm dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} # Deploy to gh pages branch From 34f16fdb843b45d9ca1d09906fa803d7ec7f4687 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:23:20 -0700 Subject: [PATCH 03/33] Update build-and-publish-reports.yml --- .github/workflows/build-and-publish-reports.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 463e7e1..7ed2fcb 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -45,22 +45,22 @@ jobs: - uses: ipfs/aegir/actions/cache-node-modules@master # TODO: Migrate reports to use npx - name: Generate report (Pinata) - if: ${{ matrix.service === 'pinata' }} + if: ${{ matrix.service == 'pinata' }} run: npm dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (Estuary) - if: ${{ matrix.service === 'estuary' }} + if: ${{ matrix.service == 'estuary' }} run: npm dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (NFT.storage) - if: ${{ matrix.service === 'nft' }} + if: ${{ matrix.service == 'nft' }} run: npm dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} # TODO: Migrate reports to use npx - name: Generate report (web3.storage) - if: ${{ matrix.service === 'web3' }} + if: ${{ matrix.service == 'web3' }} run: npm dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} # Deploy to gh pages branch From 95182ee8c3476202fc758846d596cd3d3ff65ed4 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:30:08 -0700 Subject: [PATCH 04/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 109 +++++++++++------- 1 file changed, 67 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 7ed2fcb..8547b92 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -15,59 +15,84 @@ jobs: steps: - name: Checkout 🛎️ uses: actions/checkout@v3 - - run-compliance-checks: + pinata-compliance-checks: runs-on: ubuntu-latest - # if: secrets.PINATA_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null && secrets.ESTUARY_API_ENDPOINT != null && secrets.ESTUARY_API_TOKEN != null && secrets.NFT_API_ENDPOINT != null && secrets.NFT_API_TOKEN != null && secrets.WEB3_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null - strategy: - fail-fast: false - matrix: - service: [pinata, estuary, nft, web3] - # include: - # - service: pinata - # endpoint: ${{ secrets.PINATA_API_ENDPOINT }} - # token: ${{secrets.PINATA_API_TOKEN}} - # - service: estuary - # endpoint: ${{ secrets.ESTUARY_API_ENDPOINT }} - # token: ${{secrets.ESTUARY_API_TOKEN}} - # - service: nft - # endpoint: ${{ secrets.NFT_API_ENDPOINT }} - # token: ${{secrets.NFT_API_TOKEN}} - # - service: web3 - # endpoint: ${{ secrets.WEB3_API_ENDPOINT }} - # token: ${{secrets.WEB3_API_TOKEN}} - - concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + needs: [checkout] + steps: + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} + estuary-compliance-checks: + runs-on: ubuntu-latest + needs: [checkout] + steps: + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} + nft-compliance-checks: + runs-on: ubuntu-latest + needs: [checkout] + steps: + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} + web3-compliance-checks: + runs-on: ubuntu-latest + needs: [checkout] steps: - - name: Checkout 🛎️ - uses: actions/checkout@v3 - - uses: ipfs/aegir/actions/cache-node-modules@master - # TODO: Migrate reports to use npx - - name: Generate report (Pinata) - if: ${{ matrix.service == 'pinata' }} - run: npm dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} + - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - # TODO: Migrate reports to use npx - - name: Generate report (Estuary) - if: ${{ matrix.service == 'estuary' }} - run: npm dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} + # run-compliance-checks: + # runs-on: ubuntu-latest + # # if: secrets.PINATA_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null && secrets.ESTUARY_API_ENDPOINT != null && secrets.ESTUARY_API_TOKEN != null && secrets.NFT_API_ENDPOINT != null && secrets.NFT_API_TOKEN != null && secrets.WEB3_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null + # strategy: + # fail-fast: false + # matrix: + # service: [pinata, estuary, nft, web3] + # # include: + # # - service: pinata + # # endpoint: ${{ secrets.PINATA_API_ENDPOINT }} + # # token: ${{secrets.PINATA_API_TOKEN}} + # # - service: estuary + # # endpoint: ${{ secrets.ESTUARY_API_ENDPOINT }} + # # token: ${{secrets.ESTUARY_API_TOKEN}} + # # - service: nft + # # endpoint: ${{ secrets.NFT_API_ENDPOINT }} + # # token: ${{secrets.NFT_API_TOKEN}} + # # - service: web3 + # # endpoint: ${{ secrets.WEB3_API_ENDPOINT }} + # # token: ${{secrets.WEB3_API_TOKEN}} - # TODO: Migrate reports to use npx - - name: Generate report (NFT.storage) - if: ${{ matrix.service == 'nft' }} - run: npm dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} + # concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + # steps: + # - name: Checkout 🛎️ + # uses: actions/checkout@v3 - # TODO: Migrate reports to use npx - - name: Generate report (web3.storage) - if: ${{ matrix.service == 'web3' }} - run: npm dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} + # - uses: ipfs/aegir/actions/cache-node-modules@master + # # TODO: Migrate reports to use npx + # - name: Generate report (Pinata) + # if: ${{ matrix.service == 'pinata' }} + # run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} + + # # TODO: Migrate reports to use npx + # - name: Generate report (Estuary) + # if: ${{ matrix.service == 'estuary' }} + # run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} + + # # TODO: Migrate reports to use npx + # - name: Generate report (NFT.storage) + # if: ${{ matrix.service == 'nft' }} + # run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} + + # # TODO: Migrate reports to use npx + # - name: Generate report (web3.storage) + # if: ${{ matrix.service == 'web3' }} + # run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} # Deploy to gh pages branch deploy: if: success() - concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. runs-on: ubuntu-latest + needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] + concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. steps: ## Cron jobs - name: Scheduled deployment From 38e68f98573a1b13694c85b7e2cb8785ed3329f9 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:31:34 -0700 Subject: [PATCH 05/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 8547b92..2487df4 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -10,33 +10,41 @@ on: pull_request: branches: [ main ] jobs: - checkout: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v3 + # checkout: + # runs-on: ubuntu-latest + # steps: + # - name: Checkout 🛎️ + # uses: actions/checkout@v3 pinata-compliance-checks: runs-on: ubuntu-latest needs: [checkout] steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} estuary-compliance-checks: runs-on: ubuntu-latest needs: [checkout] steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} nft-compliance-checks: runs-on: ubuntu-latest needs: [checkout] steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} web3-compliance-checks: runs-on: ubuntu-latest needs: [checkout] steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} From 369c29dd10e87337fad0dc5d6b6a11bf92a606d9 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:33:17 -0700 Subject: [PATCH 06/33] Update build-and-publish-reports.yml --- .github/workflows/build-and-publish-reports.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 2487df4..1d85fe2 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -17,7 +17,7 @@ jobs: # uses: actions/checkout@v3 pinata-compliance-checks: runs-on: ubuntu-latest - needs: [checkout] + # needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -25,7 +25,7 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} estuary-compliance-checks: runs-on: ubuntu-latest - needs: [checkout] + # needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -33,7 +33,7 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} nft-compliance-checks: runs-on: ubuntu-latest - needs: [checkout] + # needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -41,7 +41,7 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} web3-compliance-checks: runs-on: ubuntu-latest - needs: [checkout] + # needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 From 07a93148872f2a9f33454c646c6bfce358fc4383 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:37:44 -0700 Subject: [PATCH 07/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 66 +++---------------- 1 file changed, 10 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 1d85fe2..a897493 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -10,14 +10,15 @@ on: pull_request: branches: [ main ] jobs: - # checkout: - # runs-on: ubuntu-latest - # steps: - # - name: Checkout 🛎️ - # uses: actions/checkout@v3 + checkout: + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v3 + - uses: ipfs/aegir/actions/cache-node-modules@master pinata-compliance-checks: runs-on: ubuntu-latest - # needs: [checkout] + needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -25,7 +26,7 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} estuary-compliance-checks: runs-on: ubuntu-latest - # needs: [checkout] + needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -33,7 +34,7 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} nft-compliance-checks: runs-on: ubuntu-latest - # needs: [checkout] + needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 @@ -41,60 +42,13 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} web3-compliance-checks: runs-on: ubuntu-latest - # needs: [checkout] + needs: [checkout] steps: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - # run-compliance-checks: - # runs-on: ubuntu-latest - # # if: secrets.PINATA_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null && secrets.ESTUARY_API_ENDPOINT != null && secrets.ESTUARY_API_TOKEN != null && secrets.NFT_API_ENDPOINT != null && secrets.NFT_API_TOKEN != null && secrets.WEB3_API_ENDPOINT != null && secrets.PINATA_API_TOKEN != null - # strategy: - # fail-fast: false - # matrix: - # service: [pinata, estuary, nft, web3] - # # include: - # # - service: pinata - # # endpoint: ${{ secrets.PINATA_API_ENDPOINT }} - # # token: ${{secrets.PINATA_API_TOKEN}} - # # - service: estuary - # # endpoint: ${{ secrets.ESTUARY_API_ENDPOINT }} - # # token: ${{secrets.ESTUARY_API_TOKEN}} - # # - service: nft - # # endpoint: ${{ secrets.NFT_API_ENDPOINT }} - # # token: ${{secrets.NFT_API_TOKEN}} - # # - service: web3 - # # endpoint: ${{ secrets.WEB3_API_ENDPOINT }} - # # token: ${{secrets.WEB3_API_TOKEN}} - - # concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. - # steps: - # - name: Checkout 🛎️ - # uses: actions/checkout@v3 - - # - uses: ipfs/aegir/actions/cache-node-modules@master - # # TODO: Migrate reports to use npx - # - name: Generate report (Pinata) - # if: ${{ matrix.service == 'pinata' }} - # run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} - - # # TODO: Migrate reports to use npx - # - name: Generate report (Estuary) - # if: ${{ matrix.service == 'estuary' }} - # run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} - - # # TODO: Migrate reports to use npx - # - name: Generate report (NFT.storage) - # if: ${{ matrix.service == 'nft' }} - # run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} - - # # TODO: Migrate reports to use npx - # - name: Generate report (web3.storage) - # if: ${{ matrix.service == 'web3' }} - # run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - # Deploy to gh pages branch deploy: if: success() From 3fbf1f7274b9252d3df5ae9e2ead68ad521c3c80 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:41:54 -0700 Subject: [PATCH 08/33] Update build-and-publish-reports.yml --- .github/workflows/build-and-publish-reports.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index a897493..4ba6810 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -72,6 +72,6 @@ jobs: uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self - BRANCH: gh-pages-${github.sha} + BRANCH: gh-pages-${{github.sha}} FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From de1c3d7a87ee38bf78b0764eeddb13f3ef1371ef Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 17:52:55 -0700 Subject: [PATCH 09/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 4ba6810..2fb6755 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -50,15 +50,15 @@ jobs: - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} # Deploy to gh pages branch - deploy: - if: success() + + ## Cron jobs + deploy-from-schedule: + if: success() && (github.event.schedule != null || github.event.pusher != null) runs-on: ubuntu-latest needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. steps: - ## Cron jobs - name: Scheduled deployment - if: github.event.schedule != null || github.event.pusher != null uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self @@ -66,12 +66,24 @@ jobs: FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ## PRs should push to branch other than primary `gh-pages` branch + ## PRs should push to branch other than primary `gh-pages` branch + deploy-from-PR: + if: success() && github.event.pull_request != null + runs-on: ubuntu-latest + needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] + concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + steps: + - name: Create branch for PR + uses: peterjgrainger/action-create-branch@v2.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: gh-pages-${{ github.event.pull_request.head.sha }} + sha: '${{ github.event.pull_request.head.sha }}' - name: Deployment for PR - if: github.event.pull_request != null uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self - BRANCH: gh-pages-${{github.sha}} + BRANCH: gh-pages-${{ github.event.pull_request.head.sha }} FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 59750e5b2645d4f3b444ca15d3fbf6654c446fdf Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 31 May 2022 18:30:55 -0700 Subject: [PATCH 10/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 2fb6755..dda8537 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -24,6 +24,15 @@ jobs: uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} + - uses: actions/upload-artifact@v2 + with: + name: pinata-logs + path: docs/api.pinata.cloud + - uses: actions/upload-artifact@v2 + with: + name: pinata-report + path: docs/api.pinata.cloud.md + estuary-compliance-checks: runs-on: ubuntu-latest needs: [checkout] @@ -32,6 +41,15 @@ jobs: uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} + - uses: actions/upload-artifact@v2 + with: + name: estuary-logs + path: docs/api.estuary.tech + - uses: actions/upload-artifact@v2 + with: + name: estuary-report + path: docs/api.estuary.tech.md + nft-compliance-checks: runs-on: ubuntu-latest needs: [checkout] @@ -40,6 +58,15 @@ jobs: uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} + - uses: actions/upload-artifact@v2 + with: + name: nft-logs + path: docs/nft.storage + - uses: actions/upload-artifact@v2 + with: + name: nft-report + path: docs/nft.storage.md + web3-compliance-checks: runs-on: ubuntu-latest needs: [checkout] @@ -48,6 +75,14 @@ jobs: uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} + - uses: actions/upload-artifact@v2 + with: + name: web3-logs + path: docs/api.web3.storage + - uses: actions/upload-artifact@v2 + with: + name: web3-report + path: docs/api.web3.storage.md # Deploy to gh pages branch @@ -79,7 +114,31 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: branch: gh-pages-${{ github.event.pull_request.head.sha }} - sha: '${{ github.event.pull_request.head.sha }}' + # sha: '${{ github.event.pull_request.head.sha }}' + - uses: actions/download-artifact@v2 + with: + name: pinata-logs + - uses: actions/download-artifact@v2 + with: + name: pinata-report + - uses: actions/download-artifact@v2 + with: + name: estuary-logs + - uses: actions/download-artifact@v2 + with: + name: estuary-report + - uses: actions/download-artifact@v2 + with: + name: nft-logs + - uses: actions/download-artifact@v2 + with: + name: nft-report + - uses: actions/download-artifact@v2 + with: + name: web3-logs + - uses: actions/download-artifact@v2 + with: + name: web3-report - name: Deployment for PR uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: From 6bb0d7034b87c02d6cd182fcb1485576d61e5d3b Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:42:53 -0700 Subject: [PATCH 11/33] attempt to use github cache --- .../workflows/build-and-publish-reports.yml | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index dda8537..3e8d786 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -16,6 +16,7 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master + pinata-compliance-checks: runs-on: ubuntu-latest needs: [checkout] @@ -23,6 +24,10 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -40,6 +45,10 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -57,6 +66,10 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -74,6 +87,10 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -93,6 +110,10 @@ jobs: needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. steps: + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - name: Scheduled deployment uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: @@ -108,6 +129,10 @@ jobs: needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. steps: + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs - name: Create branch for PR uses: peterjgrainger/action-create-branch@v2.0.1 env: @@ -139,10 +164,4 @@ jobs: - uses: actions/download-artifact@v2 with: name: web3-report - - name: Deployment for PR - uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 - env: - REPO: self - BRANCH: gh-pages-${{ github.event.pull_request.head.sha }} - FOLDER: docs - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + From 081e0a361505ce42663440e9711f39875663d5ed Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:48:10 -0700 Subject: [PATCH 12/33] Update build-and-publish-reports.yml --- .github/workflows/build-and-publish-reports.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 3e8d786..c602a5e 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -28,6 +28,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -49,6 +50,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -70,6 +72,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -91,6 +94,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -114,6 +118,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - name: Scheduled deployment uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: @@ -133,6 +138,7 @@ jobs: uses: actions/cache@v3 with: path: docs + key: ${{ github.event.pull_request.head.sha }} - name: Create branch for PR uses: peterjgrainger/action-create-branch@v2.0.1 env: @@ -164,4 +170,10 @@ jobs: - uses: actions/download-artifact@v2 with: name: web3-report - + - name: Deployment for PR + uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 + env: + REPO: self + BRANCH: gh-pages-${{ github.event.pull_request.head.sha }} + FOLDER: docs + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 2bd87c4608242c79576a76b73ffef15faec81cce Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:56:02 -0700 Subject: [PATCH 13/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 72 ++++++++++--------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index c602a5e..2808900 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-pinata - run: npm run dev-start -- -s ${{ secrets.PINATA_API_ENDPOINT }} ${{secrets.PINATA_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -50,7 +50,7 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-estuary - run: npm run dev-start -- -s ${{ secrets.ESTUARY_API_ENDPOINT }} ${{secrets.ESTUARY_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -72,7 +72,7 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-nft - run: npm run dev-start -- -s ${{ secrets.NFT_API_ENDPOINT }} ${{secrets.NFT_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -94,7 +94,7 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-web3 - run: npm run dev-start -- -s ${{ secrets.WEB3_API_ENDPOINT }} ${{secrets.WEB3_API_TOKEN}} - uses: actions/upload-artifact@v2 with: @@ -118,7 +118,22 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-pinata + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-estuary + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-nft + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-web3 - name: Scheduled deployment uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: @@ -138,42 +153,33 @@ jobs: uses: actions/cache@v3 with: path: docs - key: ${{ github.event.pull_request.head.sha }} + key: ${{ github.sha }}-pinata + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-estuary + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-nft + - name: Reports Cache + uses: actions/cache@v3 + with: + path: docs + key: ${{ github.sha }}-web3 - name: Create branch for PR uses: peterjgrainger/action-create-branch@v2.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - branch: gh-pages-${{ github.event.pull_request.head.sha }} - # sha: '${{ github.event.pull_request.head.sha }}' - - uses: actions/download-artifact@v2 - with: - name: pinata-logs - - uses: actions/download-artifact@v2 - with: - name: pinata-report - - uses: actions/download-artifact@v2 - with: - name: estuary-logs - - uses: actions/download-artifact@v2 - with: - name: estuary-report - - uses: actions/download-artifact@v2 - with: - name: nft-logs - - uses: actions/download-artifact@v2 - with: - name: nft-report - - uses: actions/download-artifact@v2 - with: - name: web3-logs - - uses: actions/download-artifact@v2 - with: - name: web3-report + branch: gh-pages-${{ github.sha }} + # sha: '${{ github.sha }}' - name: Deployment for PR uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 env: REPO: self - BRANCH: gh-pages-${{ github.event.pull_request.head.sha }} + BRANCH: gh-pages-${{ github.sha }} FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From acbccbe33be069b42ccb1e7e28966327dea7dfc0 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:09:17 -0700 Subject: [PATCH 14/33] Update build-and-publish-reports.yml --- .../workflows/build-and-publish-reports.yml | 94 ++++++++++--------- 1 file changed, 52 insertions(+), 42 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 2808900..05d0341 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -1,6 +1,16 @@ name: Build and publish compliance reports on: workflow_dispatch: + inputs: + type: + description: 'Emulate either schedule, push, or pull_request' + required: true + default: 'schedule' + type: choice + options: + - schedule + - push + - pull_request schedule: - cron: "0 0 * * 6" # Run at 00:00 on every saturday push: @@ -109,7 +119,7 @@ jobs: ## Cron jobs deploy-from-schedule: - if: success() && (github.event.schedule != null || github.event.pusher != null) + if: success() && (github.event.schedule != null || github.event.pusher != null || github.event.inputs.type == 'schedule' || github.event.inputs.type == 'push') runs-on: ubuntu-latest needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. @@ -142,44 +152,44 @@ jobs: FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - ## PRs should push to branch other than primary `gh-pages` branch - deploy-from-PR: - if: success() && github.event.pull_request != null - runs-on: ubuntu-latest - needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] - concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. - steps: - - name: Reports Cache - uses: actions/cache@v3 - with: - path: docs - key: ${{ github.sha }}-pinata - - name: Reports Cache - uses: actions/cache@v3 - with: - path: docs - key: ${{ github.sha }}-estuary - - name: Reports Cache - uses: actions/cache@v3 - with: - path: docs - key: ${{ github.sha }}-nft - - name: Reports Cache - uses: actions/cache@v3 - with: - path: docs - key: ${{ github.sha }}-web3 - - name: Create branch for PR - uses: peterjgrainger/action-create-branch@v2.0.1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - branch: gh-pages-${{ github.sha }} - # sha: '${{ github.sha }}' - - name: Deployment for PR - uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 - env: - REPO: self - BRANCH: gh-pages-${{ github.sha }} - FOLDER: docs - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # ## PRs should push to branch other than primary `gh-pages` branch + # deploy-from-PR: + # if: success() && github.event.pull_request != null + # runs-on: ubuntu-latest + # needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] + # concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + # steps: + # - name: Reports Cache + # uses: actions/cache@v3 + # with: + # path: docs + # key: ${{ github.sha }}-pinata + # - name: Reports Cache + # uses: actions/cache@v3 + # with: + # path: docs + # key: ${{ github.sha }}-estuary + # - name: Reports Cache + # uses: actions/cache@v3 + # with: + # path: docs + # key: ${{ github.sha }}-nft + # - name: Reports Cache + # uses: actions/cache@v3 + # with: + # path: docs + # key: ${{ github.sha }}-web3 + # - name: Create branch for PR + # uses: peterjgrainger/action-create-branch@v2.0.1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # branch: gh-pages-${{ github.sha }} + # # sha: '${{ github.sha }}' + # - name: Deployment for PR + # uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 + # env: + # REPO: self + # BRANCH: gh-pages-${{ github.sha }} + # FOLDER: docs + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d08a8f3cc3dfef220c9e788975d46dd60419576f Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Wed, 1 Jun 2022 14:28:11 -0700 Subject: [PATCH 15/33] fix: md->html conversion requires extra newline --- src/output/getExpectationsMarkdown.ts | 2 +- src/output/getHeader.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output/getExpectationsMarkdown.ts b/src/output/getExpectationsMarkdown.ts index 22196fa..e1bcc02 100644 --- a/src/output/getExpectationsMarkdown.ts +++ b/src/output/getExpectationsMarkdown.ts @@ -14,7 +14,7 @@ const getExpectationsMarkdown = (details: Compli return `### Expectations (${successes}/${checks} successful) - ${lineItems.join('\n ')} + ${lineItems.join('\n\n ')} ` } diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index 5a04c3d..5251698 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -21,7 +21,7 @@ const getHeader = (details: Array Date: Wed, 1 Jun 2022 14:44:45 -0700 Subject: [PATCH 16/33] fix: render body as multiline json in reports --- src/utils/fetchSafe/getText.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/utils/fetchSafe/getText.ts b/src/utils/fetchSafe/getText.ts index 332cdd0..089b183 100644 --- a/src/utils/fetchSafe/getText.ts +++ b/src/utils/fetchSafe/getText.ts @@ -9,7 +9,13 @@ const handleLargeRequests = async () => await sleep(TIMEOUT_SECONDS * 1000).then const getText = async (response: ApiCall['response']): Promise => { const actualTextPromise = new Promise((resolve, reject) => { response.clone().text().then((result) => { - resolve(result) + try { + const obj = JSON.parse(result) + const text = JSON.stringify(obj, null, 2) + resolve(text) + } catch { + resolve(result) + } }, (error) => { reject(error) }) From 2b4ce758d412c6a3f0b08fffdfecc134f8141db3 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 08:28:18 -0700 Subject: [PATCH 17/33] chore: remove extraneous comments --- .../workflows/build-and-publish-reports.yml | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 05d0341..f21d4fa 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -151,45 +151,3 @@ jobs: BRANCH: gh-pages FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - # ## PRs should push to branch other than primary `gh-pages` branch - # deploy-from-PR: - # if: success() && github.event.pull_request != null - # runs-on: ubuntu-latest - # needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] - # concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. - # steps: - # - name: Reports Cache - # uses: actions/cache@v3 - # with: - # path: docs - # key: ${{ github.sha }}-pinata - # - name: Reports Cache - # uses: actions/cache@v3 - # with: - # path: docs - # key: ${{ github.sha }}-estuary - # - name: Reports Cache - # uses: actions/cache@v3 - # with: - # path: docs - # key: ${{ github.sha }}-nft - # - name: Reports Cache - # uses: actions/cache@v3 - # with: - # path: docs - # key: ${{ github.sha }}-web3 - # - name: Create branch for PR - # uses: peterjgrainger/action-create-branch@v2.0.1 - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # with: - # branch: gh-pages-${{ github.sha }} - # # sha: '${{ github.sha }}' - # - name: Deployment for PR - # uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 - # env: - # REPO: self - # BRANCH: gh-pages-${{ github.sha }} - # FOLDER: docs - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From b81ffb220f3684df471380a5bc4e1f7a47b505ed Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 09:11:34 -0700 Subject: [PATCH 18/33] feat: add date and revision to report output --- package-lock.json | 24 ++++++++++++++++++++++++ package.json | 2 ++ src/ApiCall.ts | 5 ++++- src/output/getHeader.ts | 16 +++++++++++++--- src/output/reporting.ts | 4 ++-- src/types.d.ts | 7 ++++++- src/utils/gitHash.ts | 11 +++++++++++ 7 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 src/utils/gitHash.ts diff --git a/package-lock.json b/package-lock.json index 5ce88eb..961b0de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "@hapi/joi": "^17.1.1", "@ipfs-shipyard/pinning-service-client": "^1.0.1", "fetch-ponyfill": "^7.1.0", + "git-rev": "^0.2.1", "go-ipfs": "^0.12.1", "ipfs": "^0.62.3", "ipfs-core": "^0.14.3", @@ -32,6 +33,7 @@ "pinning-service-compliance": "dist/src/index.js" }, "devDependencies": { + "@types/git-rev": "^0.2.0", "@types/hapi__joi": "^17.1.8", "@types/marked": "^4.0.3", "@types/marked-terminal": "^3.1.3", @@ -3379,6 +3381,12 @@ "@types/ms": "*" } }, + "node_modules/@types/git-rev": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@types/git-rev/-/git-rev-0.2.0.tgz", + "integrity": "sha512-BF+uvTxHCxPpf2BlArsIn8eHVTr7oUqq2oEA3F2Os6X9UGohHE6m7jKpHzsEqvQTQVOeBCyFMxjp7YvGk748ow==", + "dev": true + }, "node_modules/@types/hapi__joi": { "version": "17.1.8", "resolved": "https://registry.npmjs.org/@types/hapi__joi/-/hapi__joi-17.1.8.tgz", @@ -10853,6 +10861,11 @@ "xtend": "~4.0.1" } }, + "node_modules/git-rev": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/git-rev/-/git-rev-0.2.1.tgz", + "integrity": "sha512-p6OU8kZpeGHYqGpwnSD5/8IIERooiQp0p6On3T7ngcugnjhbmihvgMwCK2iun8ytn7FynsCPN+jRclR29hgOBg==" + }, "node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -30131,6 +30144,12 @@ "@types/ms": "*" } }, + "@types/git-rev": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@types/git-rev/-/git-rev-0.2.0.tgz", + "integrity": "sha512-BF+uvTxHCxPpf2BlArsIn8eHVTr7oUqq2oEA3F2Os6X9UGohHE6m7jKpHzsEqvQTQVOeBCyFMxjp7YvGk748ow==", + "dev": true + }, "@types/hapi__joi": { "version": "17.1.8", "resolved": "https://registry.npmjs.org/@types/hapi__joi/-/hapi__joi-17.1.8.tgz", @@ -35706,6 +35725,11 @@ } } }, + "git-rev": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/git-rev/-/git-rev-0.2.1.tgz", + "integrity": "sha512-p6OU8kZpeGHYqGpwnSD5/8IIERooiQp0p6On3T7ngcugnjhbmihvgMwCK2iun8ytn7FynsCPN+jRclR29hgOBg==" + }, "glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", diff --git a/package.json b/package.json index a2785f9..d5714ce 100644 --- a/package.json +++ b/package.json @@ -126,6 +126,7 @@ "rebuild": "npm run clean && npm install && npm run build" }, "devDependencies": { + "@types/git-rev": "^0.2.0", "@types/hapi__joi": "^17.1.8", "@types/marked": "^4.0.3", "@types/marked-terminal": "^3.1.3", @@ -146,6 +147,7 @@ "@hapi/joi": "^17.1.1", "@ipfs-shipyard/pinning-service-client": "^1.0.1", "fetch-ponyfill": "^7.1.0", + "git-rev": "^0.2.1", "go-ipfs": "^0.12.1", "ipfs": "^0.62.3", "ipfs-core": "^0.14.3", diff --git a/src/ApiCall.ts b/src/ApiCall.ts index a6e72fd..db78f90 100644 --- a/src/ApiCall.ts +++ b/src/ApiCall.ts @@ -16,6 +16,7 @@ import { Icons } from './utils/constants.js' import { globalReport } from './utils/report.js' import { isError } from './guards/isError.js' import { getTextAndJson } from './utils/fetchSafe/getTextAndJson.js' +import { gitHash } from './utils/gitHash.js' interface ApiCallOptions { pair: ServiceAndTokenPair @@ -255,8 +256,10 @@ class ApiCall) { diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index 5251698..ef8b8fc 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -1,14 +1,20 @@ -import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' +import type { ComplianceCheckDetails, PinsApiResponseTypes, Revision } from '../types.js' -type RequiredHeaderProps = Pick, 'title' | 'successful' | 'pair'> +type RequiredHeaderProps = Pick, 'title' | 'successful' | 'pair' | 'date' | 'revision'> const getHeader = (details: Array>) => { const endpointUrl = details[0].pair[0] let checks = 0 let successes = 0 - const titles = details.map(({ title, successful }) => { + let dateString: string | null = null + let revisionString: Revision | null = null + const titles = details.map(({ title, successful, date, revision }) => { checks++ + dateString = dateString ?? date.toISOString() + if (revisionString == null) { + revisionString = `Revision: [${revision}](https://github.com/ipfs-shipyard/pinning-service-compliance/commit/${revision})` + } if (successful) { successes++ return `✓ ${title}` @@ -19,6 +25,10 @@ const getHeader = (details: Array>> = new Map( const addApiCallToReport = async (apiCall: ApiCall) => { try { - const { pair, errors, title, httpRequest, result, response, expectationResults, successful, text, validationResult } = await apiCall.reportData() + const { date, revision, pair, errors, title, httpRequest, result, response, expectationResults, successful, text, validationResult } = await apiCall.reportData() const { url, headers: requestHeaders } = httpRequest const method = httpRequest.method ?? 'Unknown' const requestBody = await httpRequest.text() const responseBody = text ?? '' const hostname = getHostnameFromUrl(url) - const headerProps: RequiredHeaderProps = { pair, title, successful } + const headerProps: RequiredHeaderProps = { pair, title, successful, date, revision } const complianceCheckDetails: ComplianceCheckDetails = { ...headerProps, errors: errors.map((expectationError) => expectationError.error), diff --git a/src/types.d.ts b/src/types.d.ts index 335f63d..c6b6793 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -94,6 +94,8 @@ interface ComplianceCheckResponse { body: string } +type Revision = string + interface ComplianceCheckDetails { pair: ServiceAndTokenPair errors: Error[] @@ -106,6 +108,8 @@ interface ComplianceCheckDetails { response: ComplianceCheckResponse result: T | null expectationResults: ExpectationResult[] + date: Date + revision: Revision } // eslint-disable-next-line @typescript-eslint/dot-notation @@ -127,5 +131,6 @@ export type { PinningSpecJoiSchema, ServiceAndTokenPair, ImplementableMethods, - PinsApiResponseTypes + PinsApiResponseTypes, + Revision } diff --git a/src/utils/gitHash.ts b/src/utils/gitHash.ts new file mode 100644 index 0000000..ef2f928 --- /dev/null +++ b/src/utils/gitHash.ts @@ -0,0 +1,11 @@ +import git from 'git-rev' + +import type { Revision } from '../types.js' + +const gitHash = async (): Promise => { + return await new Promise((resolve) => { + git.short((commitHash) => resolve(commitHash)) + }) +} + +export { gitHash } From 7bf0131dcc69e6a29bcbb5d668a9f2130de5364a Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 09:15:03 -0700 Subject: [PATCH 19/33] chore: use more explicit github action job names --- .github/workflows/build-and-publish-reports.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index f21d4fa..f0c4671 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -27,7 +27,7 @@ jobs: uses: actions/checkout@v3 - uses: ipfs/aegir/actions/cache-node-modules@master - pinata-compliance-checks: + check-pinata-compliance: runs-on: ubuntu-latest needs: [checkout] steps: @@ -49,7 +49,7 @@ jobs: name: pinata-report path: docs/api.pinata.cloud.md - estuary-compliance-checks: + check-estuary-compliance: runs-on: ubuntu-latest needs: [checkout] steps: @@ -71,7 +71,7 @@ jobs: name: estuary-report path: docs/api.estuary.tech.md - nft-compliance-checks: + check-nft-dot-storage-compliance: runs-on: ubuntu-latest needs: [checkout] steps: @@ -93,7 +93,7 @@ jobs: name: nft-report path: docs/nft.storage.md - web3-compliance-checks: + check-web3-dot-storage-compliance: runs-on: ubuntu-latest needs: [checkout] steps: @@ -121,7 +121,7 @@ jobs: deploy-from-schedule: if: success() && (github.event.schedule != null || github.event.pusher != null || github.event.inputs.type == 'schedule' || github.event.inputs.type == 'push') runs-on: ubuntu-latest - needs: [pinata-compliance-checks, estuary-compliance-checks, nft-compliance-checks, web3-compliance-checks] + needs: [check-pinata-compliance, check-estuary-compliance, check-nft-dot-storage-compliance, check-web3-dot-storage-compliance] concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. steps: - name: Reports Cache From e62c17d97ebd4925a3520fafa2109a74195925bc Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 14:12:09 -0700 Subject: [PATCH 20/33] fix: do not squash gh-pages history --- .github/workflows/build-and-publish-reports.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index f0c4671..20ec50b 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -151,3 +151,4 @@ jobs: BRANCH: gh-pages FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SQUASH_HISTORY: false From acd9fbce7aa5b4d9fd569d699885b7661c648b54 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:26:32 -0700 Subject: [PATCH 21/33] feat: Link to headers from summary, cleanup revision markdown --- src/ApiCall.ts | 5 +--- src/output/complianceCheckHeader.ts | 9 ++++++ src/output/getHeader.ts | 46 +++++++++++++++++++++-------- src/output/getReportEntry.ts | 6 ++-- src/output/linkToCommit.ts | 3 ++ src/output/linkToHeading.ts | 23 +++++++++++++++ src/output/linkToNpm.ts | 5 ++++ src/output/reporting.ts | 14 +++++---- src/types.d.ts | 2 -- src/utils/gitHash.ts | 21 +++++++++++-- 10 files changed, 105 insertions(+), 29 deletions(-) create mode 100644 src/output/complianceCheckHeader.ts create mode 100644 src/output/linkToCommit.ts create mode 100644 src/output/linkToHeading.ts create mode 100644 src/output/linkToNpm.ts diff --git a/src/ApiCall.ts b/src/ApiCall.ts index db78f90..a6e72fd 100644 --- a/src/ApiCall.ts +++ b/src/ApiCall.ts @@ -16,7 +16,6 @@ import { Icons } from './utils/constants.js' import { globalReport } from './utils/report.js' import { isError } from './guards/isError.js' import { getTextAndJson } from './utils/fetchSafe/getTextAndJson.js' -import { gitHash } from './utils/gitHash.js' interface ApiCallOptions { pair: ServiceAndTokenPair @@ -256,10 +255,8 @@ class ApiCall) { diff --git a/src/output/complianceCheckHeader.ts b/src/output/complianceCheckHeader.ts new file mode 100644 index 0000000..aad5259 --- /dev/null +++ b/src/output/complianceCheckHeader.ts @@ -0,0 +1,9 @@ +import { Icons } from '../utils/constants.js' + +interface ComplianceCheckHeaderProps { + title: string + successful: boolean +} +const complianceCheckHeader = ({ title, successful }: ComplianceCheckHeaderProps) => `${title} - ${successful ? `${Icons.SUCCESS} SUCCESS` : `${Icons.FAILURE} FAILED`}` + +export { complianceCheckHeader } diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index ef8b8fc..ce76a81 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -1,34 +1,54 @@ -import type { ComplianceCheckDetails, PinsApiResponseTypes, Revision } from '../types.js' +import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' +import { gitHash } from '../utils/gitHash.js' +import { complianceCheckHeader } from './complianceCheckHeader.js' +import { linkToCommit } from './linkToCommit.js' +import { linkToHeading } from './linkToHeading.js' +import { linkToNpm } from './linkToNpm.js' -type RequiredHeaderProps = Pick, 'title' | 'successful' | 'pair' | 'date' | 'revision'> +type RequiredHeaderProps = Pick, 'title' | 'successful' | 'pair'> -const getHeader = (details: Array>) => { +interface HeaderOptions { + markdownLinks: boolean +} +const getHeader = async (details: Array>, options: HeaderOptions = { markdownLinks: true }) => { const endpointUrl = details[0].pair[0] let checks = 0 let successes = 0 + const useMarkdownLinks = options.markdownLinks + + const dateString = (new Date()).toISOString() + let revisionString: string | null = null + let previousRevisionString: string | null = null + + try { + const currentRevision = await gitHash() + const prevRevision = await gitHash(1) - let dateString: string | null = null - let revisionString: Revision | null = null - const titles = details.map(({ title, successful, date, revision }) => { + revisionString = useMarkdownLinks ? linkToCommit(currentRevision) : currentRevision + previousRevisionString = useMarkdownLinks ? linkToCommit(prevRevision) : prevRevision + } catch { + revisionString = useMarkdownLinks ? linkToNpm() : process.env.npm_package_version as string + } + + const titles = details.map(({ title, successful }) => { checks++ - dateString = dateString ?? date.toISOString() - if (revisionString == null) { - revisionString = `Revision: [${revision}](https://github.com/ipfs-shipyard/pinning-service-compliance/commit/${revision})` - } + const titleLink = useMarkdownLinks ? linkToHeading(title, complianceCheckHeader({ title, successful })) : title if (successful) { successes++ - return `✓ ${title}` + return `✓ ${titleLink}` } - return `✘ ${title}` + return `✘ ${titleLink}` }) return ` # ${endpointUrl} compliance: -Date: ${dateString ?? '(Error getting date)'} +Execution Date: ${dateString ?? '(Error getting date)'} Revision: ${revisionString ?? '(Error getting revision)'} +Previous Revision: ${previousRevisionString ?? '(Error getting previous revision)'} + ## Summary (${successes}/${checks} successful) ${titles.join('\n\n ')} diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index 7123552..726b8e8 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -2,15 +2,15 @@ import { inspect } from 'util' import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' -import { Icons } from '../utils/constants.js' import { stringifyHeaders } from '../utils/stringifyHeaders.js' +import { complianceCheckHeader } from './complianceCheckHeader.js' import { getExpectationsMarkdown } from './getExpectationsMarkdown.js' import { joiValidationAsMarkdown } from './joiValidationAsMarkdown.js' const getReportEntry = (details: ComplianceCheckDetails): string => { - const { request, response, title, url, method, validationResult, result: clientParsedResult } = details + const { request, response, title, url, method, validationResult, result: clientParsedResult, successful } = details - const reportEntry = `## ${title} - ${details.successful ? `${Icons.SUCCESS} SUCCESS` : `${Icons.FAILURE} FAILED`} + const reportEntry = `## ${complianceCheckHeader({ title, successful })} ${getExpectationsMarkdown(details)} diff --git a/src/output/linkToCommit.ts b/src/output/linkToCommit.ts new file mode 100644 index 0000000..25fe3ed --- /dev/null +++ b/src/output/linkToCommit.ts @@ -0,0 +1,3 @@ +const linkToCommit = (revision: string) => `[${revision}](https://github.com/ipfs-shipyard/pinning-service-compliance/commit/${revision})` + +export { linkToCommit } diff --git a/src/output/linkToHeading.ts b/src/output/linkToHeading.ts new file mode 100644 index 0000000..a622d4b --- /dev/null +++ b/src/output/linkToHeading.ts @@ -0,0 +1,23 @@ +/** + * Create a markdown link to a heading on the same page (hash link) + * + * This function attempts to create a link that matches the generated links occurring automatically when github renders a markdown document. + * + * @example + * https://github.com/ipfs-shipyard/pinning-service-compliance/blob/f19db8c708b9a9ef72437db2510eaa45840d382c/nft.storage.md#can-create-and-then-delete-a-new-pin----success + * + * @param text - The text to use for the link + * @param headerText - The text of the header we want to link to + * + * @returns {string} A Markdown link to the header in the form of [text](converted_headerText) + */ +const linkToHeading = (text: string, headerText = text) => { + const link = headerText + .replace(/['=()/\\:,✓✘]/g, '') // remove invalid characters first + .replace(/[^a-zA-Z0-9]/g, '-') // replace any remaining non-alphanumeric characters with hyphens + .toLowerCase() + + return `[${text}](#${link})` +} + +export { linkToHeading } diff --git a/src/output/linkToNpm.ts b/src/output/linkToNpm.ts new file mode 100644 index 0000000..f1dbc28 --- /dev/null +++ b/src/output/linkToNpm.ts @@ -0,0 +1,5 @@ + +const packageName = process.env.npm_package_name as string +const linkToNpm = (version = process.env.npm_package_version as string) => `[${version}](https://www.npmjs.com/package/${packageName}/v/${version})` + +export { linkToNpm } diff --git a/src/output/reporting.ts b/src/output/reporting.ts index a0977c1..4804eb5 100644 --- a/src/output/reporting.ts +++ b/src/output/reporting.ts @@ -65,14 +65,14 @@ const reportSummaryInfo: Map>> = new Map( const addApiCallToReport = async (apiCall: ApiCall) => { try { - const { date, revision, pair, errors, title, httpRequest, result, response, expectationResults, successful, text, validationResult } = await apiCall.reportData() + const { pair, errors, title, httpRequest, result, response, expectationResults, successful, text, validationResult } = await apiCall.reportData() const { url, headers: requestHeaders } = httpRequest const method = httpRequest.method ?? 'Unknown' const requestBody = await httpRequest.text() const responseBody = text ?? '' const hostname = getHostnameFromUrl(url) - const headerProps: RequiredHeaderProps = { pair, title, successful, date, revision } + const headerProps: RequiredHeaderProps = { pair, title, successful } const complianceCheckDetails: ComplianceCheckDetails = { ...headerProps, errors: errors.map((expectationError) => expectationError.error), @@ -112,11 +112,15 @@ const addApiCallToReport = async (apiCall: ApiCa const createReport = async (hostname: string, details: Array>) => { const reportFilePath = getReportFilePath(hostname) - const header = getHeader(details) + // Write console output first + const noMarkdownLinksHeader = await getHeader(details, { markdownLinks: false }) // Don't give npx users cluttered output. + const consoleHeader = `${noMarkdownLinksHeader.replace(/#+ /gm, '')}\nSee the full report at ${reportFilePath}` + logger.info(consoleHeader, { messageOnly: true }) + + // write file content + const header = await getHeader(details) const fileContents = await readFile(reportFilePath, 'utf8') await writeFile(reportFilePath, header + fileContents) - const consoleHeader = `${header.replace(/#+ /gm, '')}\nSee the full report at ${reportFilePath}` - logger.info(consoleHeader, { messageOnly: true }) } const writeHeaders = async () => { diff --git a/src/types.d.ts b/src/types.d.ts index c6b6793..31c5cae 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -108,8 +108,6 @@ interface ComplianceCheckDetails { response: ComplianceCheckResponse result: T | null expectationResults: ExpectationResult[] - date: Date - revision: Revision } // eslint-disable-next-line @typescript-eslint/dot-notation diff --git a/src/utils/gitHash.ts b/src/utils/gitHash.ts index ef2f928..49430cb 100644 --- a/src/utils/gitHash.ts +++ b/src/utils/gitHash.ts @@ -2,9 +2,26 @@ import git from 'git-rev' import type { Revision } from '../types.js' -const gitHash = async (): Promise => { +/** + * Provides the git hash of HEAD by default, in short format. + * + * This function will not work when called from npx, because the npm package doesn't come with the git repo. Please + * catch any errors and display npm package version instead. + * + * @param {number} [fromHead=0] - How many commits from the head you want the hash of + * + * @returns {Revision} The hash of the requested commit + */ +const gitHash = async (fromHead = 0): Promise => { return await new Promise((resolve) => { - git.short((commitHash) => resolve(commitHash)) + if (fromHead === 0) { + git.short((commitHash) => resolve(commitHash)) + } else { + // @see https://www.npmjs.com/package/git-rev#logfunction-array--- + git.log((log) => { + resolve(log[fromHead][0].slice(0, 7)) + }) + } }) } From e0780c6d2d21442409e125875d3081df78ff83cc Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 6 Jun 2022 17:37:54 -0700 Subject: [PATCH 22/33] fix: attempt to catch git-rev error --- src/index.ts | 8 ++------ src/utils/gitHash.ts | 18 +++++++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index c124d1a..c7b97c7 100755 --- a/src/index.ts +++ b/src/index.ts @@ -46,14 +46,10 @@ const main = async () => { } const getUncaughtListener = (type: 'unhandledRejection' | 'uncaughtException' | 'uncaughtExceptionMonitor'): NodeJS.UncaughtExceptionListener => (err, origin) => { - logger.error(type, { error: err }) + logger.error(type, err, origin) writeSync( process.stderr.fd, - `Caught exception: ${JSON.stringify(err, null, 2)}\n` - ) - writeSync( - process.stdout.fd, - `Caught exception: ${JSON.stringify(err, null, 2)}\n` + `Caught exception: ${JSON.stringify({ err, origin }, null, 2)}\n` ) } process.on('uncaughtExceptionMonitor', getUncaughtListener('uncaughtExceptionMonitor')) diff --git a/src/utils/gitHash.ts b/src/utils/gitHash.ts index 49430cb..4ceb19b 100644 --- a/src/utils/gitHash.ts +++ b/src/utils/gitHash.ts @@ -13,14 +13,18 @@ import type { Revision } from '../types.js' * @returns {Revision} The hash of the requested commit */ const gitHash = async (fromHead = 0): Promise => { - return await new Promise((resolve) => { - if (fromHead === 0) { - git.short((commitHash) => resolve(commitHash)) - } else { + return await new Promise((resolve, reject) => { + try { + if (fromHead === 0) { + git.short((commitHash) => resolve(commitHash)) + } else { // @see https://www.npmjs.com/package/git-rev#logfunction-array--- - git.log((log) => { - resolve(log[fromHead][0].slice(0, 7)) - }) + git.log((log) => { + resolve(log[fromHead][0].slice(0, 7)) + }) + } + } catch (err) { + reject(err) } }) } From 6fd6b9848c5f307772f73d972b349fad61f6877c Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 12:42:50 -0700 Subject: [PATCH 23/33] fix: Remove hardcoded delay for pinata --- src/utils/getQueue.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/utils/getQueue.ts b/src/utils/getQueue.ts index c13c095..30ad33c 100644 --- a/src/utils/getQueue.ts +++ b/src/utils/getQueue.ts @@ -1,18 +1,13 @@ -// import { TokenBucketLimiter } from '@dutu/rate-limiter' import PQueue from 'p-queue' type QueueInstance = InstanceType const queues: Map = new Map() -// const getQueue = (endpointUrl: string, options: ConstructorParameters[0] = { concurrency: 1, intervalCap: 1, interval: 1000 }): QueueInstance => { const getQueue = (endpointUrl: string, options: ConstructorParameters[0] = { concurrency: 1, intervalCap: 1, interval: 1000 }): PQueue => { if (queues.has(endpointUrl)) { return queues.get(endpointUrl) as QueueInstance } - let newQueueLimiter = new PQueue(options) - if (endpointUrl.includes('pinata')) { - newQueueLimiter = new PQueue({ ...options, interval: 5000 }) - } + const newQueueLimiter = new PQueue(options) queues.set(endpointUrl, newQueueLimiter) From 1196d4164680a589f015a8f3010bb5ff5d4c02ad Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 12:43:46 -0700 Subject: [PATCH 24/33] feat: gh-pages has informative commit messages --- .github/workflows/build-and-publish-reports.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 20ec50b..5768a5f 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -152,3 +152,4 @@ jobs: FOLDER: docs GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SQUASH_HISTORY: false + MESSAGE: "Update published reports with changes from {sha} with message:\n{msg}" From 16a5774221be9bbef18a92a1bec913e7808d16e2 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 13:01:41 -0700 Subject: [PATCH 25/33] chore: Reports with no changes from previous will create commit --- .github/workflows/build-and-publish-reports.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-and-publish-reports.yml b/.github/workflows/build-and-publish-reports.yml index 5768a5f..a4e77cd 100644 --- a/.github/workflows/build-and-publish-reports.yml +++ b/.github/workflows/build-and-publish-reports.yml @@ -153,3 +153,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SQUASH_HISTORY: false MESSAGE: "Update published reports with changes from {sha} with message:\n{msg}" + SKIP_EMPTY_COMMITS: false From eda2a20458026f26ad19fd2977339cc56e283f91 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 13:16:56 -0700 Subject: [PATCH 26/33] feat: add report history link * Also handles failures when there is no git history now --- src/output/getHeader.ts | 23 +++++++++++++++++++---- src/output/linkToCommit.ts | 4 +++- src/output/linkToGithubRepo.ts | 5 +++++ src/utils/constants.ts | 7 ++++++- src/utils/gitHash.ts | 6 +++++- src/utils/markdownLinkToTextLabel.ts | 9 +++++++++ 6 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 src/output/linkToGithubRepo.ts create mode 100644 src/utils/markdownLinkToTextLabel.ts diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index ce76a81..b254fb7 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -1,7 +1,11 @@ import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' +import { getHostnameFromUrl } from '../utils/getHostnameFromUrl.js' import { gitHash } from '../utils/gitHash.js' +import { logger } from '../utils/logs.js' +import { markdownLinkToTextLabel } from '../utils/markdownLinkToTextLabel.js' import { complianceCheckHeader } from './complianceCheckHeader.js' import { linkToCommit } from './linkToCommit.js' +import { linkToGithubRepo } from './linkToGithubRepo.js' import { linkToHeading } from './linkToHeading.js' import { linkToNpm } from './linkToNpm.js' @@ -12,9 +16,10 @@ interface HeaderOptions { } const getHeader = async (details: Array>, options: HeaderOptions = { markdownLinks: true }) => { const endpointUrl = details[0].pair[0] + const useMarkdownLinks = options.markdownLinks + const hostname = getHostnameFromUrl(endpointUrl) let checks = 0 let successes = 0 - const useMarkdownLinks = options.markdownLinks const dateString = (new Date()).toISOString() let revisionString: string | null = null @@ -22,13 +27,19 @@ const getHeader = async (details: Array { checks++ @@ -40,6 +51,8 @@ const getHeader = async (details: Array `[${revision}](https://github.com/ipfs-shipyard/pinning-service-compliance/commit/${revision})` +import { sourceRepoUrl } from '../utils/constants.js' + +const linkToCommit = (revision: string) => `[${revision}](${sourceRepoUrl}/commit/${revision})` export { linkToCommit } diff --git a/src/output/linkToGithubRepo.ts b/src/output/linkToGithubRepo.ts new file mode 100644 index 0000000..884fe07 --- /dev/null +++ b/src/output/linkToGithubRepo.ts @@ -0,0 +1,5 @@ +import { sourceRepoUrl } from '../utils/constants.js' + +const linkToGithubRepo = (displayText: string, pathSuffix?: string) => `[${displayText}](${sourceRepoUrl}${pathSuffix != null ? `/${pathSuffix}` : ''})` + +export { linkToGithubRepo } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 324abd4..1eb2923 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -16,6 +16,9 @@ const downloadDir = resolve(_dirname, '..', '..', 'downloaded') const generatedDir = resolve(_dirname, '..', '..', 'generated') const docsDir = resolve(_dirname, '..', '..', 'docs') +const publishedReportsUrl = 'https://ipfs-shipyard.github.io/pinning-service-compliance' +const sourceRepoUrl = 'https://github.com/ipfs-shipyard/pinning-service-compliance' + enum Icons { SUCCESS = '✓', FAILURE = '✘', @@ -30,5 +33,7 @@ export { specFile, specLocation, specVersion, - Icons + Icons, + publishedReportsUrl, + sourceRepoUrl } diff --git a/src/utils/gitHash.ts b/src/utils/gitHash.ts index 4ceb19b..f985601 100644 --- a/src/utils/gitHash.ts +++ b/src/utils/gitHash.ts @@ -20,7 +20,11 @@ const gitHash = async (fromHead = 0): Promise => { } else { // @see https://www.npmjs.com/package/git-rev#logfunction-array--- git.log((log) => { - resolve(log[fromHead][0].slice(0, 7)) + try { + resolve(log[fromHead][0].slice(0, 7)) + } catch (err) { + reject(err) + } }) } } catch (err) { diff --git a/src/utils/markdownLinkToTextLabel.ts b/src/utils/markdownLinkToTextLabel.ts new file mode 100644 index 0000000..9e9d1d1 --- /dev/null +++ b/src/utils/markdownLinkToTextLabel.ts @@ -0,0 +1,9 @@ +/** + * @example + * var foo = '[Report History](https://github.com/ipfs-shipyard/pinning-service-compliance/commits/gh-pages/api.pinata.cloud.md)' + * var bar = markdownLinkToTextLabel(foo) + * // bar = 'Report History: https://github.com/ipfs-shipyard/pinning-service-compliance/commits/gh-pages/api.pinata.cloud.md' + */ +const markdownLinkToTextLabel = (markdownLink: string) => markdownLink.replace(/\[([^\]]+)\]\((.+)\)/, '$1: $2') + +export { markdownLinkToTextLabel } From 2d1ce30ef58ada0f3d0c7160636cc86938ebaf89 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 14:35:15 -0700 Subject: [PATCH 27/33] fix: Remove previous revision from header --- src/output/getHeader.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index b254fb7..4437d08 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -23,7 +23,6 @@ const getHeader = async (details: Array(details: Array { checks++ @@ -60,8 +53,6 @@ Execution Date: ${dateString ?? '(Error getting date)'} Revision: ${revisionString ?? '(Error getting revision)'} -Previous Revision: ${previousRevisionString ?? '(Error getting previous revision)'} - ${useMarkdownLinks ? reportHistory : markdownLinkToTextLabel(reportHistory)} ## Summary (${successes}/${checks} successful) From 9dfaf6c41e00d776df465e8b498e600c0a7a53ff Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 16:27:31 -0700 Subject: [PATCH 28/33] chore: rename and hide joi schema failures when empty temporary solution until #78 is done --- src/output/getReportEntry.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index 726b8e8..809490a 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -9,7 +9,7 @@ import { joiValidationAsMarkdown } from './joiValidationAsMarkdown.js' const getReportEntry = (details: ComplianceCheckDetails): string => { const { request, response, title, url, method, validationResult, result: clientParsedResult, successful } = details - + const joiValidationMarkdown = joiValidationAsMarkdown(validationResult) const reportEntry = `## ${complianceCheckHeader({ title, successful })} ${getExpectationsMarkdown(details)} @@ -28,9 +28,13 @@ ${details.errors.map((error) => { return errorOutput }).join('\n')} -#### Joi validation failures -${joiValidationAsMarkdown(validationResult)} - +${ + joiValidationMarkdown !== 'No failures' + ? `#### Response object doesn't match expected schema: +${joiValidationMarkdown} + ` + : '' +} ### Details #### Request - ${method}: ${url} From 6e74e3b60112df258cd2e9fc5f6c737e55363f57 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:54:07 -0700 Subject: [PATCH 29/33] fix: UX improvement for pass/fail/error icons fixes #76 --- src/output/getExpectationsMarkdown.ts | 5 +++-- src/output/getHeader.ts | 5 +++-- src/output/linkToHeading.ts | 4 +++- src/utils/constants.ts | 6 +++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/output/getExpectationsMarkdown.ts b/src/output/getExpectationsMarkdown.ts index e1bcc02..e4988c1 100644 --- a/src/output/getExpectationsMarkdown.ts +++ b/src/output/getExpectationsMarkdown.ts @@ -1,4 +1,5 @@ import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' +import { Icons } from '../utils/constants.js' const getExpectationsMarkdown = (details: ComplianceCheckDetails): string => { let checks = 0 @@ -7,9 +8,9 @@ const getExpectationsMarkdown = (details: Compli checks++ if (success) { successes++ - return `✓ ${title} (success)` + return `${Icons.SUCCESS} ${title} (success)` } - return `✘ ${title} (failure)` + return `${Icons.FAILURE} ${title} (failure)` }) return `### Expectations (${successes}/${checks} successful) diff --git a/src/output/getHeader.ts b/src/output/getHeader.ts index 4437d08..c166337 100644 --- a/src/output/getHeader.ts +++ b/src/output/getHeader.ts @@ -1,4 +1,5 @@ import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' +import { Icons } from '../utils/constants.js' import { getHostnameFromUrl } from '../utils/getHostnameFromUrl.js' import { gitHash } from '../utils/gitHash.js' import { logger } from '../utils/logs.js' @@ -39,9 +40,9 @@ const getHeader = async (details: Array { const link = headerText - .replace(/['=()/\\:,✓✘]/g, '') // remove invalid characters first + .replace(/['=()/\\:,]/g, '') // remove invalid characters first + .replace(/[🟢]/gu, '') // remove invalid characters first + .replace(/[❌]/gu, '') // remove invalid characters first .replace(/[^a-zA-Z0-9]/g, '-') // replace any remaining non-alphanumeric characters with hyphens .toLowerCase() diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 1eb2923..681dc53 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -20,9 +20,9 @@ const publishedReportsUrl = 'https://ipfs-shipyard.github.io/pinning-service-com const sourceRepoUrl = 'https://github.com/ipfs-shipyard/pinning-service-compliance' enum Icons { - SUCCESS = '✓', - FAILURE = '✘', - ERROR = '⚠' + SUCCESS = '🟢', + FAILURE = '❌', + ERROR = '⚠️' } export { From 0782e4411273592dc04bc672bd495fc1a3023baf Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:54:54 -0700 Subject: [PATCH 30/33] fix: add json identifier to code in markdown fixes #77 --- src/output/getReportEntry.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index 809490a..675b1f6 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -48,11 +48,11 @@ ${stringifyHeaders(request.headers)} ${request.body} \`\`\` #### Response data from ${url} -\`\`\` +\`\`\`json ${inspect(response.json, { depth: 4 })} \`\`\` #### Response data after being parsed by RemotePinningServiceClient -\`\`\` +\`\`\`json ${inspect(clientParsedResult, { depth: 4 })} \`\`\` #### Response - ${response.statusText} (${response.status}) From 933fbc6cd292f2dd5516e41ef99850d19081cd94 Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:56:12 -0700 Subject: [PATCH 31/33] fix: Error output uses icon and header It will not show if there are no errors --- src/ApiCall.ts | 12 ++++++++++-- src/output/getErrorsMarkdown.ts | 19 +++++++++++++++++++ src/output/getReportEntry.ts | 22 ++++++++-------------- 3 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 src/output/getErrorsMarkdown.ts diff --git a/src/ApiCall.ts b/src/ApiCall.ts index a6e72fd..1310af7 100644 --- a/src/ApiCall.ts +++ b/src/ApiCall.ts @@ -16,6 +16,7 @@ import { Icons } from './utils/constants.js' import { globalReport } from './utils/report.js' import { isError } from './guards/isError.js' import { getTextAndJson } from './utils/fetchSafe/getTextAndJson.js' +import { isResponse } from './guards/isResponse.js' interface ApiCallOptions { pair: ServiceAndTokenPair @@ -115,12 +116,19 @@ class ApiCall { this.result = result diff --git a/src/output/getErrorsMarkdown.ts b/src/output/getErrorsMarkdown.ts new file mode 100644 index 0000000..8bfb430 --- /dev/null +++ b/src/output/getErrorsMarkdown.ts @@ -0,0 +1,19 @@ +import { inspect } from 'util' + +import { Icons } from '../utils/constants.js' + +const errorToMarkdown = (error: Error) => { + let errorOutput = '' + if (error.stack != null) { + errorOutput = ` + ${Icons.ERROR} ${error.stack}` + } else if (error.name != null && error.message != null) { + errorOutput = `${Icons.ERROR} ${error.name} - ${error.message}` + } else { + errorOutput = `${Icons.ERROR} ${inspect(error)}` + } + return errorOutput +} +const getErrorsMarkdown = (errors: Error[]) => errors.map(errorToMarkdown).join('\n') + +export { getErrorsMarkdown } diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index 675b1f6..e36fb1b 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -4,29 +4,23 @@ import { inspect } from 'util' import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' import { stringifyHeaders } from '../utils/stringifyHeaders.js' import { complianceCheckHeader } from './complianceCheckHeader.js' +import { getErrorsMarkdown } from './getErrorsMarkdown.js' import { getExpectationsMarkdown } from './getExpectationsMarkdown.js' import { joiValidationAsMarkdown } from './joiValidationAsMarkdown.js' const getReportEntry = (details: ComplianceCheckDetails): string => { - const { request, response, title, url, method, validationResult, result: clientParsedResult, successful } = details + const { request, response, title, url, method, validationResult, result: clientParsedResult, successful, errors } = details const joiValidationMarkdown = joiValidationAsMarkdown(validationResult) const reportEntry = `## ${complianceCheckHeader({ title, successful })} ${getExpectationsMarkdown(details)} -${details.errors.map((error) => { - let errorOutput = '' - if (error.name != null && error.message != null) { - errorOutput = `* ${error.name} - ${error.message}` - if (error.stack != null) { - errorOutput += ` - * ${error.stack}` - } - } else { - errorOutput = `* ${inspect(error)}` - } - return errorOutput -}).join('\n')} +${ + errors.length > 0 + ? `### Errors during run +${getErrorsMarkdown(errors)}` + : '' +} ${ joiValidationMarkdown !== 'No failures' From 0251812d864e028cb5c73dfda305e730a6c8fd2c Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Mon, 13 Jun 2022 13:41:18 -0700 Subject: [PATCH 32/33] feat: fix json highlighting in reports fixes #77 --- src/output/getReportEntry.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index e36fb1b..db71938 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -1,6 +1,3 @@ - -import { inspect } from 'util' - import type { ComplianceCheckDetails, PinsApiResponseTypes } from '../types.js' import { stringifyHeaders } from '../utils/stringifyHeaders.js' import { complianceCheckHeader } from './complianceCheckHeader.js' @@ -43,11 +40,11 @@ ${request.body} \`\`\` #### Response data from ${url} \`\`\`json -${inspect(response.json, { depth: 4 })} +${JSON.stringify(response.json, null, 2)} \`\`\` #### Response data after being parsed by RemotePinningServiceClient \`\`\`json -${inspect(clientParsedResult, { depth: 4 })} +${JSON.stringify(clientParsedResult, null, 2)} \`\`\` #### Response - ${response.statusText} (${response.status}) ##### Headers From a5f8eff1ebf0969754ba1c8f711df9fd3780c3ce Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Tue, 14 Jun 2022 14:02:12 +0200 Subject: [PATCH 33/33] =?UTF-8?q?style:=20change=20body=20order=20raw?= =?UTF-8?q?=E2=86=92json=E2=86=92parsed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes things easier to reason about: In this order, each step has more strictness. --- src/output/getReportEntry.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/output/getReportEntry.ts b/src/output/getReportEntry.ts index db71938..f285576 100644 --- a/src/output/getReportEntry.ts +++ b/src/output/getReportEntry.ts @@ -28,8 +28,10 @@ ${joiValidationMarkdown} } ### Details -#### Request - ${method}: ${url} - +#### Request +\`\`\` +${method} ${url} +\`\`\` ##### Headers \`\`\`json ${stringifyHeaders(request.headers)} @@ -38,15 +40,11 @@ ${stringifyHeaders(request.headers)} \`\`\`json ${request.body} \`\`\` -#### Response data from ${url} -\`\`\`json -${JSON.stringify(response.json, null, 2)} + +#### Response \`\`\` -#### Response data after being parsed by RemotePinningServiceClient -\`\`\`json -${JSON.stringify(clientParsedResult, null, 2)} +${response.status} ${response.statusText} \`\`\` -#### Response - ${response.statusText} (${response.status}) ##### Headers \`\`\`json ${stringifyHeaders(response.headers)} @@ -55,6 +53,15 @@ ${stringifyHeaders(response.headers)} \`\`\`json ${response.body} \`\`\` + +##### Body (as JSON) +\`\`\`json +${JSON.stringify(response.json, null, 2)} +\`\`\` +##### Body (parsed by [pinning-service-client](https://www.npmjs.com/package/@ipfs-shipyard/pinning-service-client)) +\`\`\`json +${JSON.stringify(clientParsedResult, null, 2)} +\`\`\` ` return reportEntry