From 95acc3299e7f16ad67748e9664f5af6625e0dabd Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:01:56 -0500 Subject: [PATCH 1/8] ci: update global workflows (#34) --- .github/workflows/automerge.yml | 4 ++-- .github/workflows/yaml-lint.yml | 34 +++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 7ff83e0a..0ac82a7a 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Autoapproving - uses: hmarr/auto-approve-action@v2 + uses: hmarr/auto-approve-action@v3 with: github-token: "${{ secrets.GITHUB_TOKEN }}" @@ -44,7 +44,7 @@ jobs: steps: - name: Automerging - uses: pascalgn/automerge-action@v0.15.3 + uses: pascalgn/automerge-action@v0.15.5 env: BASE_BRANCHES: nightly GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/yaml-lint.yml b/.github/workflows/yaml-lint.yml index f2e07218..a8c97e3a 100644 --- a/.github/workflows/yaml-lint.yml +++ b/.github/workflows/yaml-lint.yml @@ -17,6 +17,24 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Find additional files + id: find-files + run: | + # space separated list of files + FILES=.clang-format + + # empty placeholder + FOUND="" + + for FILE in ${FILES}; do + if [ -f "$FILE" ] + then + FOUND="$FOUND $FILE" + fi + done + + echo "found=${FOUND}" >> $GITHUB_OUTPUT + - name: yaml lint id: yaml-lint uses: ibiqlik/action-yamllint@v3 @@ -30,17 +48,13 @@ jobs: line-length: max: 120 truthy: - allowed-values: ['true', 'false', 'on'] # GitHub uses "on" for workflow event triggers + # GitHub uses "on" for workflow event triggers + # .clang-format file has options of "Yes" "No" that will be caught by this, so changed to "warning" + allowed-values: ['true', 'false', 'on'] check-keys: true - level: error + level: warning + file_or_dir: . ${{ steps.find-files.outputs.found }} - name: Log run: | - echo ${{ steps.yaml-lint.outputs.logfile }} - - - name: Upload logs - uses: actions/upload-artifact@v3 - if: failure() - with: - name: yamllint-logfile - path: ${{ steps.yaml-lint.outputs.logfile }} + cat "${{ steps.yaml-lint.outputs.logfile }}" >> $GITHUB_STEP_SUMMARY From ead4459b4f188b51173151074a18b94d9c0ce034 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Tue, 15 Nov 2022 09:06:10 -0500 Subject: [PATCH 2/8] ci: update global docker (#35) --- .github/workflows/ci-docker.yml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml index f4a50695..f1e94794 100644 --- a/.github/workflows/ci-docker.yml +++ b/.github/workflows/ci-docker.yml @@ -31,7 +31,7 @@ jobs: FOUND=false fi - echo "::set-output name=dockerfile::${FOUND}" + echo "dockerfile=${FOUND}" >> $GITHUB_OUTPUT outputs: dockerfile: ${{ steps.check.outputs.dockerfile }} @@ -42,12 +42,23 @@ jobs: if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }} runs-on: ubuntu-latest steps: - - name: Lint Dockerfile + - name: Checkout uses: actions/checkout@v3 - - uses: hadolint/hadolint-action@v2.1.0 + - name: Hadolint + id: hadolint + uses: hadolint/hadolint-action@v3.0.0 with: dockerfile: ./Dockerfile + ignore: DL3008,DL3013,DL3016,DL3018,DL3028,DL3059 + output-file: ./hadolint.log + verbose: true + + - name: Log + if: failure() + run: | + echo "Hadolint outcome: ${{ steps.hadolint.outcome }}" >> $GITHUB_STEP_SUMMARY + cat "./hadolint.log" >> $GITHUB_STEP_SUMMARY check_changelog: name: Check Changelog @@ -128,12 +139,12 @@ jobs: # read the platforms from `.docker_platforms` PLATFORMS=$(<.docker_platforms) - echo ::set-output name=branch::${BRANCH} - echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - echo ::set-output name=commit::${COMMIT} - echo ::set-output name=platforms::${PLATFORMS} - echo ::set-output name=push::${PUSH} - echo ::set-output name=tags::${TAGS} + echo "branch=${BRANCH}" >> $GITHUB_OUTPUT + echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT + echo "commit=${COMMIT}" >> $GITHUB_OUTPUT + echo "platforms=${PLATFORMS}" >> $GITHUB_OUTPUT + echo "push=${PUSH}" >> $GITHUB_OUTPUT + echo "tags=${TAGS}" >> $GITHUB_OUTPUT - name: Set Up QEMU uses: docker/setup-qemu-action@v2 From 17a8e17225b10b39097312db689882eaede77d2d Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:19:29 -0500 Subject: [PATCH 3/8] lock python version for docs theme --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 235c06c2..abad590d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -5,4 +5,4 @@ numpydoc==0.9.2;python_version<"3" git+https://github.com/LizardByte/plexhints.git#egg=plexhints # type hinting library for plex development pytest==4.6.11;python_version<"3" Sphinx==1.8.6;python_version<"3" -sphinx-rtd-theme==1.0.0 +sphinx-rtd-theme==1.1.1;python_version<"3" From a9b207672a642e97a9a8abd9f591220276c2c108 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Wed, 28 Dec 2022 11:43:28 -0500 Subject: [PATCH 4/8] ci: update global python (#44) --- .github/workflows/python-flake8.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-flake8.yml b/.github/workflows/python-flake8.yml index 463fb8a2..411b1afe 100644 --- a/.github/workflows/python-flake8.yml +++ b/.github/workflows/python-flake8.yml @@ -24,7 +24,8 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip setuptools flake8 + # pin flake8 before v6.0.0 due to removal of support for type comments (required for Python 2.7 type hints) + python -m pip install --upgrade pip setuptools "flake8<6" - name: Test with flake8 run: | From 6124e9d2f65cfb798fdbc2ef47476d5e1bfcb060 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Wed, 28 Dec 2022 11:47:05 -0500 Subject: [PATCH 5/8] ci: update release notifier (#45) --- .github/workflows/release-notifier.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-notifier.yml b/.github/workflows/release-notifier.yml index 7a2c13ea..bea36033 100644 --- a/.github/workflows/release-notifier.yml +++ b/.github/workflows/release-notifier.yml @@ -12,6 +12,7 @@ on: jobs: discord: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: discord @@ -27,6 +28,7 @@ jobs: color: 0xFF4500 facebook_group: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: facebook-post-action @@ -40,6 +42,7 @@ jobs: url: ${{ github.event.release.html_url }} facebook_page: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: facebook-post-action @@ -53,10 +56,11 @@ jobs: url: ${{ github.event.release.html_url }} reddit: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: reddit - uses: bluwy/release-for-reddit-action@v1 # https://github.com/bluwy/release-for-reddit-action + uses: bluwy/release-for-reddit-action@v2 # https://github.com/bluwy/release-for-reddit-action with: username: ${{ secrets.REDDIT_USERNAME }} password: ${{ secrets.REDDIT_PASSWORD }} @@ -69,6 +73,7 @@ jobs: comment: ${{ github.event.release.body }} twitter: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: twitter From ebf90b35f12a689413b2fecb1701ee25535c1d12 Mon Sep 17 00:00:00 2001 From: LizardByte-bot <108553330+LizardByte-bot@users.noreply.github.com> Date: Wed, 28 Dec 2022 11:51:26 -0500 Subject: [PATCH 6/8] ci: update global workflows (#43) --- .github/dependabot.yml | 8 +++ .github/pr_release_template.md | 6 +- .github/workflows/auto-create-pr.yml | 1 + .github/workflows/automerge.yml | 8 ++- .github/workflows/autoupdate-labeler.yml | 71 ++++++++++++++++++++++++ .github/workflows/autoupdate.yml | 23 ++++++-- .github/workflows/issues-stale.yml | 5 +- .github/workflows/issues.yml | 3 +- .github/workflows/pull-requests.yml | 1 + 9 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/autoupdate-labeler.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b67ea638..2b757b97 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -36,3 +36,11 @@ updates: time: "00:00" target-branch: "nightly" open-pull-requests-limit: 10 + + - package-ecosystem: "gitsubmodule" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + target-branch: "nightly" + open-pull-requests-limit: 10 diff --git a/.github/pr_release_template.md b/.github/pr_release_template.md index 7c96c6b6..b6f6acf5 100644 --- a/.github/pr_release_template.md +++ b/.github/pr_release_template.md @@ -17,8 +17,12 @@ This PR was created automatically. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [ ] Dependency update (updates to dependencies) - [ ] Documentation update (changes to documentation) -- [ ] Repository update (changes to repository files) +- [ ] Repository update (changes to repository files, e.g. `.github/...`) + +## Branch Updates +- [x] I want maintainers to keep my branch updated ## Changelog Summary diff --git a/.github/workflows/auto-create-pr.yml b/.github/workflows/auto-create-pr.yml index ef19e40f..67045e0e 100644 --- a/.github/workflows/auto-create-pr.yml +++ b/.github/workflows/auto-create-pr.yml @@ -12,6 +12,7 @@ on: jobs: create_pr: + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml index 0ac82a7a..0ba55681 100644 --- a/.github/workflows/automerge.yml +++ b/.github/workflows/automerge.yml @@ -13,9 +13,10 @@ on: jobs: autoapprove: - if: > + if: >- contains(fromJson('["LizardByte-bot"]'), github.event.pull_request.user.login) && - contains(fromJson('["LizardByte-bot"]'), github.actor) + contains(fromJson('["LizardByte-bot"]'), github.actor) && + startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Autoapproving @@ -36,6 +37,7 @@ jobs: }) automerge: + if: startsWith(github.repository, 'LizardByte/') needs: [autoapprove] runs-on: ubuntu-latest concurrency: @@ -49,7 +51,7 @@ jobs: BASE_BRANCHES: nightly GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} GITHUB_LOGIN: ${{ secrets.GH_BOT_NAME }} - MERGE_LABELS: "" + MERGE_LABELS: "!dependencies" MERGE_METHOD: "squash" MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})" MERGE_DELETE_BRANCH: true diff --git a/.github/workflows/autoupdate-labeler.yml b/.github/workflows/autoupdate-labeler.yml new file mode 100644 index 00000000..5e426ad7 --- /dev/null +++ b/.github/workflows/autoupdate-labeler.yml @@ -0,0 +1,71 @@ +--- +# This action is centrally managed in https://github.com//.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in +# the above-mentioned repo. + +name: Label PR autoupdate + +on: + pull_request_target: + types: + - edited + - opened + - reopened + - synchronize + +jobs: + label_pr: + if: >- + startsWith(github.repository, 'LizardByte/') && + contains(github.event.pull_request.body, fromJSON('"] I want maintainers to keep my branch updated"')) + runs-on: ubuntu-latest + env: + GH_TOKEN: ${{ github.token }} + steps: + - name: Check if member + id: org_member + run: | + status="true" + gh api \ + -H "Accept: application/vnd.github+json" \ + /orgs/${{ github.repository_owner }}/members/${{ github.actor }} || status="false" + + echo "result=${status}" >> $GITHUB_OUTPUT + + - name: Label autoupdate + if: >- + steps.org_member.outputs.result == 'true' && + contains(github.event.pull_request.labels.*.name, 'autoupdate') == false && + contains(github.event.pull_request.body, + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == true + + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['autoupdate'] + }) + + - name: Unlabel autoupdate + if: >- + contains(github.event.pull_request.labels.*.name, 'autoupdate') && + ( + (github.event.action == 'synchronize' && steps.org_member.outputs.result == 'false') || + (contains(github.event.pull_request.body, + fromJSON('"\n- [x] I want maintainers to keep my branch updated"')) == false + ) + ) + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GH_BOT_TOKEN }} + script: | + github.rest.issues.removeLabel({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + name: ['autoupdate'] + }) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index f32e65c7..25ea03fa 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -3,8 +3,9 @@ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in # the above-mentioned repo. -# This workflow is designed to work with: -# - automerge workflows +# This workflow is designed to work with the following workflows: +# - automerge +# - autoupdate-labeler # It uses GitHub Action that auto-updates pull requests branches, when changes are pushed to their destination branch. # Auto-updating to the latest destination branch works only in the context of upstream repo and not forks. @@ -17,7 +18,7 @@ on: - 'nightly' jobs: - autoupdate-for-bot: + autoupdate: name: Autoupdate autoapproved PR created in the upstream if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest @@ -25,8 +26,20 @@ jobs: - name: Update uses: docker://chinthakagodawita/autoupdate-action:v1 env: + EXCLUDED_LABELS: "central_dependency,dependencies" GITHUB_TOKEN: '${{ secrets.GH_BOT_TOKEN }}' PR_FILTER: "labelled" PR_LABELS: "autoupdate" - PR_READY_STATE: "ready_for_review" - MERGE_CONFLICT_ACTION: "ignore" + PR_READY_STATE: "all" + MERGE_CONFLICT_ACTION: "fail" + + dependabot-rebase: + name: Dependabot Rebase + if: >- + startsWith(github.repository, 'LizardByte/') + runs-on: ubuntu-latest + steps: + - name: rebase + uses: "bbeesley/gha-auto-dependabot-rebase@v1.2.0" + env: + GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/issues-stale.yml b/.github/workflows/issues-stale.yml index 7baf4b9a..460eb848 100644 --- a/.github/workflows/issues-stale.yml +++ b/.github/workflows/issues-stale.yml @@ -12,10 +12,11 @@ on: jobs: stale: name: Check Stale Issues / PRs + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Stale - uses: actions/stale@v6 + uses: actions/stale@v7 with: close-issue-message: > This issue was closed because it has been stalled for 10 days with no activity. @@ -37,7 +38,7 @@ jobs: repo-token: ${{ secrets.GH_BOT_TOKEN }} - name: Invalid Template - uses: actions/stale@v6 + uses: actions/stale@v7 with: close-issue-message: > This issue was closed because the the template was not completed after 5 days. diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml index 6ba44446..db25703d 100644 --- a/.github/workflows/issues.yml +++ b/.github/workflows/issues.yml @@ -14,9 +14,10 @@ on: jobs: label: name: Label Actions + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - name: Label Actions - uses: dessant/label-actions@v2 + uses: dessant/label-actions@v3 with: github-token: ${{ secrets.GH_BOT_TOKEN }} diff --git a/.github/workflows/pull-requests.yml b/.github/workflows/pull-requests.yml index 0abc26b8..1fa3c071 100644 --- a/.github/workflows/pull-requests.yml +++ b/.github/workflows/pull-requests.yml @@ -12,6 +12,7 @@ on: jobs: check-pull-request: name: Check Pull Request + if: startsWith(github.repository, 'LizardByte/') runs-on: ubuntu-latest steps: - uses: Vankka/pr-target-branch-action@v2 From 413c2d219f590dc9d9d2daa91b2b4278baba328c Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 28 Dec 2022 12:09:20 -0500 Subject: [PATCH 7/8] autofetch plex-token (#39) --- Contents/Code/default_prefs.py | 3 +-- Contents/Code/plex_api_helper.py | 11 ++++++----- Contents/DefaultPrefs.json | 15 --------------- docs/source/about/usage.rst | 23 ----------------------- 4 files changed, 7 insertions(+), 45 deletions(-) diff --git a/Contents/Code/default_prefs.py b/Contents/Code/default_prefs.py index 38a11495..09d06844 100644 --- a/Contents/Code/default_prefs.py +++ b/Contents/Code/default_prefs.py @@ -1,6 +1,5 @@ default_prefs = dict( int_plexapi_plexapi_timeout='180', str_youtube_user='', - str_youtube_passwd='', - url_plex_server='http://localhost:32400' + str_youtube_passwd='' ) diff --git a/Contents/Code/plex_api_helper.py b/Contents/Code/plex_api_helper.py index 4d552469..fe97254f 100644 --- a/Contents/Code/plex_api_helper.py +++ b/Contents/Code/plex_api_helper.py @@ -1,5 +1,8 @@ # -*- coding: utf-8 -*- +# standard imports +import os + # plex debugging try: import plexhints # noqa: F401 @@ -33,13 +36,11 @@ def setup_plexapi(): >>> setup_plexapi() ... """ - plex_url = Prefs['url_plex_server'] - Log.Debug('Plex url: %s' % plex_url) - - plex_token = Prefs['str_plex_token'] + plex_url = 'http://localhost:32400' + plex_token = os.environ.get('PLEXTOKEN') if not plex_token: - Log.Error('Plex token not set in agent settings, cannot proceed.') + Log.Error('Plex token not found in environment, cannot proceed.') return False sess = requests.Session() diff --git a/Contents/DefaultPrefs.json b/Contents/DefaultPrefs.json index 214683f0..ec4fffe8 100644 --- a/Contents/DefaultPrefs.json +++ b/Contents/DefaultPrefs.json @@ -20,20 +20,5 @@ "default": "", "option": "hidden", "secure": "true" - }, - { - "id": "url_plex_server", - "type": "text", - "label": "Plex Server URL", - "default": "http://localhost:32400", - "secure": "true" - }, - { - "id": "str_plex_token", - "type": "text", - "label": "Plex token", - "default": "", - "option": "hidden", - "secure": "true" } ] diff --git a/docs/source/about/usage.rst b/docs/source/about/usage.rst index 923f3fe0..5a32c86b 100644 --- a/docs/source/about/usage.rst +++ b/docs/source/about/usage.rst @@ -49,26 +49,3 @@ Description Default None - -Plex Server URL -^^^^^^^^^^^^^^^ - -Description - The URL to use for accessing the Plex server. Themerr-plex uses `python-plexapi` to upload theme songs, so must have - access to the Plex URL. - -Default - ``http://localhost:32400`` - -Plex token -^^^^^^^^^^ - -Description - The token to use for accessing the Plex server. Themerr-plex uses `python-plexapi` to upload theme songs, so this - must be set. - - .. Tip:: See `Finding an authentication token / X-Plex-Token - `_. - -Default - None From 7e87adbbe2a6d6b4fc17306a54bceb955f2ca98d Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Wed, 28 Dec 2022 12:23:16 -0500 Subject: [PATCH 8/8] Update CHANGELOG.md v0.0.6 (#46) --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddeb7b8d..ab2700da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.0.6] - 2022-12-28 +### Changed +- Plex token is now automatically fetched from the Plex python environment + ## [0.0.5] - 2022-10-15 ### Fixed - changing timeout no longer requires a Plex Media Server restart @@ -29,3 +33,10 @@ ## [0.0.1] - 2022-10-03 ### Added - Initial Release + +[0.0.1]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.1 +[0.0.2]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.2 +[0.0.3]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.3 +[0.0.4]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.4 +[0.0.5]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.5 +[0.0.6]: https://github.com/lizardbyte/themerr-plex/releases/tag/v0.0.6