diff --git a/.github/workflows/_build-dev.yml b/.github/workflows/_build-dev.yml new file mode 100644 index 000000000..449f7906d --- /dev/null +++ b/.github/workflows/_build-dev.yml @@ -0,0 +1,27 @@ +name: build-dev + +on: + workflow_call: + +jobs: + dev: + # prevent job from running twice when a PR pushes a new commit + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 + with: + node-version: "lts/*" + cache: "npm" + - name: NPM install + run: npm ci + - name: Install roku module dependencies + run: npm run ropm + - name: Build app + run: npm run build + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 + with: + name: Jellyfin-Roku-dev-${{ github.sha }} + path: ${{ github.workspace }}/build/staging + if-no-files-found: error diff --git a/.github/workflows/_build-prod.yml b/.github/workflows/_build-prod.yml new file mode 100644 index 000000000..0e2f41146 --- /dev/null +++ b/.github/workflows/_build-prod.yml @@ -0,0 +1,27 @@ +# Builds the production version of the app +name: build-prod + +on: + workflow_call: + +jobs: + prod: + if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'release-prep') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 + with: + node-version: "lts/*" + cache: "npm" + - name: NPM install + run: npm ci + - name: Install roku module dependencies + run: npm run ropm + - name: Build app for production + run: npm run build-prod + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 + with: + name: Jellyfin-Roku-v${{ env.newManVersion }}-${{ github.sha }} + path: ${{ github.workspace }}/build/staging + if-no-files-found: error diff --git a/.github/workflows/_lint-brightscript.yml b/.github/workflows/_lint-brightscript.yml new file mode 100644 index 000000000..5e7363f9a --- /dev/null +++ b/.github/workflows/_lint-brightscript.yml @@ -0,0 +1,18 @@ +name: lint-brightscript + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "lts/*" + cache: "npm" + - run: npm ci + - run: npx ropm install + - run: npm run validate + - run: npm run check-formatting diff --git a/.github/workflows/_lint-json.yml b/.github/workflows/_lint-json.yml new file mode 100644 index 000000000..2597b54d8 --- /dev/null +++ b/.github/workflows/_lint-json.yml @@ -0,0 +1,21 @@ +name: lint-json + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Clone github repo + uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "lts/*" + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Install roku package dependencies + run: npx ropm install + - name: Validate JSON syntax + run: npm run lint-json \ No newline at end of file diff --git a/.github/workflows/_lint-markdown.yml b/.github/workflows/_lint-markdown.yml new file mode 100644 index 000000000..4080166a6 --- /dev/null +++ b/.github/workflows/_lint-markdown.yml @@ -0,0 +1,22 @@ +name: lint-markdown + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Clone github repo + uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "lts/*" + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Install roku package dependencies + run: npx ropm install + - uses: xt0rted/markdownlint-problem-matcher@1a5fabfb577370cfdf5af944d418e4be3ea06f27 # v3 + - name: Lint markdown files + run: npm run lint-markdown diff --git a/.github/workflows/_lint-spelling.yml b/.github/workflows/_lint-spelling.yml new file mode 100644 index 000000000..d73a9f459 --- /dev/null +++ b/.github/workflows/_lint-spelling.yml @@ -0,0 +1,21 @@ +name: lint-spelling + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Clone github repo + uses: actions/checkout@master + - uses: actions/setup-node@master + with: + node-version: "lts/*" + cache: "npm" + - name: Install npm dependencies + run: npm ci + - name: Install roku package dependencies + run: npx ropm install + - name: Check markdown files for spelling errors + run: npm run lint-spelling diff --git a/.github/workflows/_lint-translation-files.yml b/.github/workflows/_lint-translation-files.yml new file mode 100644 index 000000000..2f7abab3a --- /dev/null +++ b/.github/workflows/_lint-translation-files.yml @@ -0,0 +1,24 @@ +name: lint-translation-files + +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + steps: + - name: Clone github repo + uses: actions/checkout@master + - name: Install xmllint and xmlstarlet using apt (from cache) + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libxml2-utils xmlstarlet + - name: Validate XML syntax + run: xmllint --noout ./locale/en_US/translations.ts + - name: Save output of duplicate check + run: echo "tsDuplicates=$(xmlstarlet sel -t -m '/TS/context/message/source' -c '.' -nl ./locale/en_US/translations.ts | sort | uniq -d | awk '{ printf "%s", $0 }')" >> $GITHUB_ENV + - name: Check for duplicates + run: xmlstarlet sel -t -m '/TS/context/message/source' -f -o ' ' -c '.' -nl ./locale/en_US/translations.ts | sort | uniq -d + - name: Duplicates found + if: env.tsDuplicates != '' + run: exit 1 diff --git a/.github/workflows/_roku-analysis.yml b/.github/workflows/_roku-analysis.yml new file mode 100644 index 000000000..d0826a334 --- /dev/null +++ b/.github/workflows/_roku-analysis.yml @@ -0,0 +1,40 @@ +name: roku-analysis + +on: + workflow_call: + +env: + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + +jobs: + static: + # don't run job on forks and prevent job from running twice when a PR pushes a new commit + if: github.repository == 'jellyfin/jellyfin-roku' && github.event_name != 'pull_request' || github.repository == 'jellyfin/jellyfin-roku' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 + with: + node-version: "lts/*" + cache: "npm" + - name: NPM install + run: npm ci + - name: Install roku module dependencies + run: npm run ropm + - name: Build dev app + if: env.BRANCH_NAME != 'master' + run: npm run build + - name: Build app for production + if: env.BRANCH_NAME == 'master' + run: npm run build-prod + - name: Setup Java + uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4 + with: + distribution: "temurin" + java-version: "21" + - name: Download the Static Channel Analysis CLI + run: | + curl -sSL "https://devtools.web.roku.com/static-channel-analysis/sca-cmd.zip" -o sca-cmd.zip + unzip sca-cmd.zip + - name: Run Roku Static Analysis + run: ./sca-cmd/bin/sca-cmd ${{ github.workspace }}/build/staging --exit error diff --git a/.github/workflows/_validate-dependencies.yml b/.github/workflows/_validate-dependencies.yml new file mode 100644 index 000000000..13408d513 --- /dev/null +++ b/.github/workflows/_validate-dependencies.yml @@ -0,0 +1,23 @@ +name: validate-dependencies + +on: + workflow_call: + +jobs: + lint-brightscript: + uses: ./.github/workflows/_lint-brightscript.yml + lint-json: + uses: ./.github/workflows/_lint-json.yml + lint-markdown: + uses: ./.github/workflows/_lint-markdown.yml + lint-spelling: + uses: ./.github/workflows/_lint-spelling.yml + lint-translation-files: + uses: ./.github/workflows/_lint-translation-files.yml + build-dev: + uses: ./.github/workflows/_build-dev.yml + build-prod: + uses: ./.github/workflows/_build-prod.yml + roku-analysis: + uses: ./.github/workflows/_roku-analysis.yml + diff --git a/.github/workflows/build-dev.yml b/.github/workflows/build-dev.yml index 70cb8b70d..cb13dd93e 100644 --- a/.github/workflows/build-dev.yml +++ b/.github/workflows/build-dev.yml @@ -6,23 +6,4 @@ on: jobs: dev: - # prevent job from running twice when a PR pushes a new commit - if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 - with: - node-version: "lts/*" - cache: "npm" - - name: NPM install - run: npm ci - - name: Install roku module dependencies - run: npm run ropm - - name: Build app - run: npm run build - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 - with: - name: Jellyfin-Roku-dev-${{ github.sha }} - path: ${{ github.workspace }}/build/staging - if-no-files-found: error + uses: ./.github/workflows/_build-dev.yml diff --git a/.github/workflows/build-prod.yml b/.github/workflows/build-prod.yml index c2575989a..11b981caa 100644 --- a/.github/workflows/build-prod.yml +++ b/.github/workflows/build-prod.yml @@ -9,22 +9,4 @@ on: jobs: prod: - if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'release-prep') }} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 - with: - node-version: "lts/*" - cache: "npm" - - name: NPM install - run: npm ci - - name: Install roku module dependencies - run: npm run ropm - - name: Build app for production - run: npm run build-prod - - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4 - with: - name: Jellyfin-Roku-v${{ env.newManVersion }}-${{ github.sha }} - path: ${{ github.workspace }}/build/staging - if-no-files-found: error + uses: ./.github/workflows/_build-prod.yml diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 000000000..1d0de36dc --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,10 @@ +name: dependencies + +on: + pull_request: + types: [labeled, opened, synchronize, reopened] + +jobs: + validate: + if: contains(github.event.pull_request.labels.*.name, 'dependencies') + uses: ./.github/workflows/_validate-dependencies.yml diff --git a/.github/workflows/lint-brightscript.yml b/.github/workflows/lint-brightscript.yml index 560bfd8be..d156b6a47 100644 --- a/.github/workflows/lint-brightscript.yml +++ b/.github/workflows/lint-brightscript.yml @@ -7,14 +7,4 @@ on: jobs: run: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - uses: actions/setup-node@master - with: - node-version: "lts/*" - cache: "npm" - - run: npm ci - - run: npx ropm install - - run: npm run validate - - run: npm run check-formatting + uses: ./.github/workflows/_lint-brightscript.yml diff --git a/.github/workflows/lint-json.yml b/.github/workflows/lint-json.yml index a5b9f9080..82fd668f8 100644 --- a/.github/workflows/lint-json.yml +++ b/.github/workflows/lint-json.yml @@ -7,17 +7,4 @@ on: jobs: run: - runs-on: ubuntu-latest - steps: - - name: Clone github repo - uses: actions/checkout@master - - uses: actions/setup-node@master - with: - node-version: "lts/*" - cache: "npm" - - name: Install npm dependencies - run: npm ci - - name: Install roku package dependencies - run: npx ropm install - - name: Validate JSON syntax - run: npm run lint-json \ No newline at end of file + uses: ./.github/workflows/_lint-json.yml \ No newline at end of file diff --git a/.github/workflows/lint-markdown.yml b/.github/workflows/lint-markdown.yml index a3a0f1a28..c00cee4e9 100644 --- a/.github/workflows/lint-markdown.yml +++ b/.github/workflows/lint-markdown.yml @@ -6,18 +6,4 @@ on: jobs: run: - runs-on: ubuntu-latest - steps: - - name: Clone github repo - uses: actions/checkout@master - - uses: actions/setup-node@master - with: - node-version: "lts/*" - cache: "npm" - - name: Install npm dependencies - run: npm ci - - name: Install roku package dependencies - run: npx ropm install - - uses: xt0rted/markdownlint-problem-matcher@1a5fabfb577370cfdf5af944d418e4be3ea06f27 # v3 - - name: Lint markdown files - run: npm run lint-markdown + uses: ./.github/workflows/_lint-markdown.yml diff --git a/.github/workflows/lint-spelling.yml b/.github/workflows/lint-spelling.yml index c2c9b8545..9a74fb681 100644 --- a/.github/workflows/lint-spelling.yml +++ b/.github/workflows/lint-spelling.yml @@ -6,17 +6,4 @@ on: jobs: run: - runs-on: ubuntu-latest - steps: - - name: Clone github repo - uses: actions/checkout@master - - uses: actions/setup-node@master - with: - node-version: "lts/*" - cache: "npm" - - name: Install npm dependencies - run: npm ci - - name: Install roku package dependencies - run: npx ropm install - - name: Check markdown files for spelling errors - run: npm run lint-spelling + uses: ./.github/workflows/_lint-spelling.yml diff --git a/.github/workflows/lint-translation-files.yml b/.github/workflows/lint-translation-files.yml index 011547e4c..ab5b55f4c 100644 --- a/.github/workflows/lint-translation-files.yml +++ b/.github/workflows/lint-translation-files.yml @@ -6,20 +6,4 @@ on: jobs: run: - runs-on: ubuntu-latest - steps: - - name: Clone github repo - uses: actions/checkout@master - - name: Install xmllint and xmlstarlet using apt (from cache) - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libxml2-utils xmlstarlet - - name: Validate XML syntax - run: xmllint --noout ./locale/en_US/translations.ts - - name: Save output of duplicate check - run: echo "tsDuplicates=$(xmlstarlet sel -t -m '/TS/context/message/source' -c '.' -nl ./locale/en_US/translations.ts | sort | uniq -d | awk '{ printf "%s", $0 }')" >> $GITHUB_ENV - - name: Check for duplicates - run: xmlstarlet sel -t -m '/TS/context/message/source' -f -o ' ' -c '.' -nl ./locale/en_US/translations.ts | sort | uniq -d - - name: Duplicates found - if: env.tsDuplicates != '' - run: exit 1 + uses: ./.github/workflows/_lint-translation-files.yml diff --git a/.github/workflows/roku-analysis.yml b/.github/workflows/roku-analysis.yml index 8a3b772f3..c8e86f9c3 100644 --- a/.github/workflows/roku-analysis.yml +++ b/.github/workflows/roku-analysis.yml @@ -8,33 +8,4 @@ env: jobs: static: - # don't run job on forks and prevent job from running twice when a PR pushes a new commit - if: github.repository == 'jellyfin/jellyfin-roku' && github.event_name != 'pull_request' || github.repository == 'jellyfin/jellyfin-roku' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 - with: - node-version: "lts/*" - cache: "npm" - - name: NPM install - run: npm ci - - name: Install roku module dependencies - run: npm run ropm - - name: Build dev app - if: env.BRANCH_NAME != 'master' - run: npm run build - - name: Build app for production - if: env.BRANCH_NAME == 'master' - run: npm run build-prod - - name: Setup Java - uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4 - with: - distribution: "temurin" - java-version: "21" - - name: Download the Static Channel Analysis CLI - run: | - curl -sSL "https://devtools.web.roku.com/static-channel-analysis/sca-cmd.zip" -o sca-cmd.zip - unzip sca-cmd.zip - - name: Run Roku Static Analysis - run: ./sca-cmd/bin/sca-cmd ${{ github.workspace }}/build/staging --exit error + uses: ./.github/workflows/_roku-analysis.yml