From 6b9774a210aa216350ff0e4d7c34421d2c661b25 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 19:10:08 +0100 Subject: [PATCH 1/4] update linting ci --- .github/workflows/linting_annotate.yml | 49 ++++++++++++++++++++++++++ .github/workflows/linting_testing.yml | 16 ++++----- 2 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/linting_annotate.yml diff --git a/.github/workflows/linting_annotate.yml b/.github/workflows/linting_annotate.yml new file mode 100644 index 00000000..298d73a7 --- /dev/null +++ b/.github/workflows/linting_annotate.yml @@ -0,0 +1,49 @@ +name: Annotate linting + +permissions: + actions: read # download artifact + checks: write # annotate + +# this is done as a seperate workflow so +# the annotater has access to write to checks (to annotate) +on: + workflow_run: + workflows: ["Linting and Testing"] + types: + - completed + +jobs: + annotate: + runs-on: ubuntu-latest + + steps: + - name: Download linting report + uses: actions/github-script@v3.1.0 + with: + script: | + var artifacts = await github.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{github.event.workflow_run.id }}, + }); + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "eslint_report.zip" + })[0]; + var download = await github.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/eslint_report.zip', Buffer.from(download.data)); + + - run: unzip eslint_report.zip + + - run: ls -la + + - name: Annotate linting + uses: ataylorme/eslint-annotate-action@v2 + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" + report-json: "eslint_report.json" diff --git a/.github/workflows/linting_testing.yml b/.github/workflows/linting_testing.yml index e51fc630..d37f2331 100644 --- a/.github/workflows/linting_testing.yml +++ b/.github/workflows/linting_testing.yml @@ -5,8 +5,7 @@ on: branches: - master - dev - pull_request_target: - types: [opened, reopened, synchronize] + pull_request: jobs: linting: @@ -24,17 +23,16 @@ jobs: - name: Install Yarn packages run: yarn install + + - name: Build Project + run: npm run build - name: Run ESLint Report run: yarn lint:report # continue on error, so it still reports it in the next step continue-on-error: true - - name: Annotate Code Linting Results - uses: ataylorme/eslint-annotate-action@v2 + - uses: actions/upload-artifact@v2 with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" - report-json: "eslint_report.json" - - - name: Build Project - run: npm run build + name: eslint_report.zip + path: eslint_report.json From b42d36c5ac51e4b72cbc7d45a578ee32d4cb46d8 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 19:12:22 +0100 Subject: [PATCH 2/4] fix lint errors --- src/backend/providers/netfilm.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/backend/providers/netfilm.ts b/src/backend/providers/netfilm.ts index ff25fbf8..9b4faafa 100644 --- a/src/backend/providers/netfilm.ts +++ b/src/backend/providers/netfilm.ts @@ -1,6 +1,10 @@ import { proxiedFetch } from "../helpers/fetch"; import { registerProvider } from "../helpers/register"; -import { MWCaptionType, MWStreamQuality, MWStreamType } from "../helpers/streams"; +import { + MWCaptionType, + MWStreamQuality, + MWStreamType, +} from "../helpers/streams"; import { MWMediaType } from "../metadata/types"; const netfilmBase = "https://net-film.vercel.app"; @@ -40,9 +44,12 @@ registerProvider({ // get stream info from media progress(75); - const watchInfo = await proxiedFetch(`/api/episode?id=${netfilmId}`, { - baseURL: netfilmBase, - }); + const watchInfo = await proxiedFetch( + `/api/episode?id=${netfilmId}`, + { + baseURL: netfilmBase, + } + ); const data = watchInfo.data; @@ -56,12 +63,14 @@ registerProvider({ url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), type: MWCaptionType.SRT, langIso: sub.language, - })) + })); return { embeds: [], stream: { - streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), + streamUrl: source.url + .replace("akm-cdn", "aws-cdn") + .replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, captions: mappedCaptions, @@ -124,12 +133,14 @@ registerProvider({ url: sub.url.replace("https://convert-srt-to-vtt.vercel.app/?url=", ""), type: MWCaptionType.SRT, langIso: sub.language, - })) + })); return { embeds: [], stream: { - streamUrl: source.url.replace("akm-cdn", "aws-cdn").replace("gg-cdn", "aws-cdn"), + streamUrl: source.url + .replace("akm-cdn", "aws-cdn") + .replace("gg-cdn", "aws-cdn"), quality: qualityMap[source.quality as QualityInMap], type: MWStreamType.HLS, captions: mappedCaptions, From 68a1470447bd03bac38f39ff2a3710c508e82e2c Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 19:17:11 +0100 Subject: [PATCH 3/4] seperate building and linting --- .github/workflows/linting_testing.yml | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linting_testing.yml b/.github/workflows/linting_testing.yml index d37f2331..1538953f 100644 --- a/.github/workflows/linting_testing.yml +++ b/.github/workflows/linting_testing.yml @@ -20,12 +20,10 @@ jobs: uses: actions/setup-node@v3 with: node-version: 18 + cache: 'yarn' - name: Install Yarn packages run: yarn install - - - name: Build Project - run: npm run build - name: Run ESLint Report run: yarn lint:report @@ -36,3 +34,23 @@ jobs: with: name: eslint_report.zip path: eslint_report.json + + building: + name: Build project + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Install Yarn packages + run: yarn install + + - name: Build Project + run: yarn build From 900c70e36acc390c3483ee4d816e7d467674de71 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Fri, 10 Mar 2023 19:25:14 +0100 Subject: [PATCH 4/4] update ci --- .github/workflows/linting_annotate.yml | 6 +++--- .github/workflows/linting_testing.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/linting_annotate.yml b/.github/workflows/linting_annotate.yml index 298d73a7..4db5b5fc 100644 --- a/.github/workflows/linting_annotate.yml +++ b/.github/workflows/linting_annotate.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Download linting report - uses: actions/github-script@v3.1.0 + uses: actions/github-script@v6 with: script: | var artifacts = await github.actions.listWorkflowRunArtifacts({ @@ -27,7 +27,7 @@ jobs: run_id: ${{github.event.workflow_run.id }}, }); var matchArtifact = artifacts.data.artifacts.filter((artifact) => { - return artifact.name == "eslint_report.zip" + return artifact.name == "eslint_report.json" })[0]; var download = await github.actions.downloadArtifact({ owner: context.repo.owner, @@ -43,7 +43,7 @@ jobs: - run: ls -la - name: Annotate linting - uses: ataylorme/eslint-annotate-action@v2 + uses: ataylorme/eslint-annotate-action@v6 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" report-json: "eslint_report.json" diff --git a/.github/workflows/linting_testing.yml b/.github/workflows/linting_testing.yml index 1538953f..53d7b5ca 100644 --- a/.github/workflows/linting_testing.yml +++ b/.github/workflows/linting_testing.yml @@ -30,9 +30,9 @@ jobs: # continue on error, so it still reports it in the next step continue-on-error: true - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: - name: eslint_report.zip + name: eslint_report.json path: eslint_report.json building: