|
| 1 | +--- |
| 2 | +name: CI |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: [master] |
| 7 | + types: [opened, synchronize, reopened] |
| 8 | + push: |
| 9 | + branches: [master] |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + setup_release: |
| 18 | + name: Setup Release |
| 19 | + outputs: |
| 20 | + publish_release: ${{ steps.setup_release.outputs.publish_release }} |
| 21 | + release_body: ${{ steps.setup_release.outputs.release_body }} |
| 22 | + release_commit: ${{ steps.setup_release.outputs.release_commit }} |
| 23 | + release_generate_release_notes: ${{ steps.setup_release.outputs.release_generate_release_notes }} |
| 24 | + release_tag: ${{ steps.setup_release.outputs.release_tag }} |
| 25 | + release_version: ${{ steps.setup_release.outputs.release_version }} |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Release |
| 32 | + id: setup_release |
| 33 | + uses: LizardByte/setup-release-action@v2024.919.143601 |
| 34 | + with: |
| 35 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 36 | + |
| 37 | + build: |
| 38 | + needs: |
| 39 | + - setup_release |
| 40 | + runs-on: ubuntu-20.04 |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + path: Media-Scripts |
| 47 | + submodules: recursive |
| 48 | + |
| 49 | + - name: Set up Python |
| 50 | + uses: LizardByte/setup-python-action@v2024.609.5111 |
| 51 | + with: |
| 52 | + python-version: '3.11' |
| 53 | + |
| 54 | + - name: Set up Python Dependencies |
| 55 | + shell: bash |
| 56 | + working-directory: Media-Scripts |
| 57 | + run: | |
| 58 | + echo "Installing Requirements" |
| 59 | + python --version |
| 60 | + python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip setuptools |
| 61 | +
|
| 62 | + # install dev requirements |
| 63 | + python -m pip install --upgrade \ |
| 64 | + -r requirements.txt |
| 65 | +
|
| 66 | + - name: Package Release |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + 7z \ |
| 70 | + "-xr!*.git*" \ |
| 71 | + "-xr!*.pyc" \ |
| 72 | + "-xr!__pycache__" \ |
| 73 | + a "./Media-Scripts.zip" "Media-Scripts" |
| 74 | +
|
| 75 | + mkdir artifacts |
| 76 | + mv ./Media-Scripts.zip ./artifacts/ |
| 77 | +
|
| 78 | + - name: Upload Artifacts |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + name: Media-Scripts |
| 82 | + if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` |
| 83 | + path: | |
| 84 | + ${{ github.workspace }}/artifacts |
| 85 | +
|
| 86 | + # - name: Create/Update GitHub Release |
| 87 | + # if: ${{ needs.setup_release.outputs.publish_release == 'true' }} |
| 88 | + # uses: LizardByte/create-release-action@v2024.919.143026 |
| 89 | + # with: |
| 90 | + # allowUpdates: true |
| 91 | + # body: ${{ needs.setup_release.outputs.release_body }} |
| 92 | + # generateReleaseNotes: ${{ needs.setup_release.outputs.release_generate_release_notes }} |
| 93 | + # name: ${{ needs.setup_release.outputs.release_tag }} |
| 94 | + # prerelease: true |
| 95 | + # tag: ${{ needs.setup_release.outputs.release_tag }} |
| 96 | + # token: ${{ secrets.GH_BOT_TOKEN }} |
| 97 | + |
| 98 | + pytest: |
| 99 | + needs: [build] |
| 100 | + strategy: |
| 101 | + fail-fast: false |
| 102 | + matrix: |
| 103 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 104 | + |
| 105 | + runs-on: ${{ matrix.os }} |
| 106 | + steps: |
| 107 | + - name: Checkout |
| 108 | + uses: actions/checkout@v4 |
| 109 | + |
| 110 | + - name: Download artifacts |
| 111 | + uses: actions/download-artifact@v4 |
| 112 | + with: |
| 113 | + name: Media-Scripts |
| 114 | + |
| 115 | + - name: Extract artifacts zip |
| 116 | + shell: bash |
| 117 | + run: | |
| 118 | + # extract zip |
| 119 | + 7z x Media-Scripts.zip -o. |
| 120 | +
|
| 121 | + # move all files from "Themerr-plex.bundle" to root, with no target directory |
| 122 | + cp -r ./Media-Scripts/. . |
| 123 | +
|
| 124 | + # remove zip |
| 125 | + rm Media-Scripts.zip |
| 126 | +
|
| 127 | + - name: Set up Python |
| 128 | + uses: LizardByte/setup-python-action@v2024.609.5111 |
| 129 | + with: |
| 130 | + python-version: '2.7' |
| 131 | + |
| 132 | + - name: Bootstrap Plex server |
| 133 | + env: |
| 134 | + PLEXAPI_PLEXAPI_TIMEOUT: "60" |
| 135 | + id: bootstrap |
| 136 | + uses: LizardByte/plexhints@v2024.809.14117 |
| 137 | + with: |
| 138 | + without_music: true |
| 139 | + without_photos: true |
| 140 | + |
| 141 | + - name: Install python dependencies |
| 142 | + shell: bash |
| 143 | + run: | |
| 144 | + python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade \ |
| 145 | + pip setuptools wheel |
| 146 | + python -m pip --no-python-version-warning --disable-pip-version-check install --no-build-isolation \ |
| 147 | + -r requirements.txt |
| 148 | +
|
| 149 | + - name: Test with pytest |
| 150 | + env: |
| 151 | + PLEX_PLUGIN_LOG_PATH: ${{ steps.bootstrap.outputs.PLEX_PLUGIN_LOG_PATH }} |
| 152 | + PLEXAPI_AUTH_SERVER_BASEURL: ${{ steps.bootstrap.outputs.PLEX_SERVER_BASEURL }} |
| 153 | + PLEXAPI_AUTH_SERVER_TOKEN: ${{ steps.bootstrap.outputs.PLEXTOKEN }} |
| 154 | + PLEXAPI_PLEXAPI_TIMEOUT: "60" |
| 155 | + PLEXTOKEN: ${{ steps.bootstrap.outputs.PLEXTOKEN }} |
| 156 | + id: test |
| 157 | + shell: bash |
| 158 | + run: | |
| 159 | + python -m pytest \ |
| 160 | + -rxXs \ |
| 161 | + --tb=native \ |
| 162 | + --verbose \ |
| 163 | + --color=yes \ |
| 164 | + --cov=Contents/Code \ |
| 165 | + tests |
| 166 | +
|
| 167 | + - name: Debug log file |
| 168 | + if: always() |
| 169 | + shell: bash |
| 170 | + run: | |
| 171 | + echo "Debugging log file" |
| 172 | + if [[ "${{ runner.os }}" == "Windows" ]]; then |
| 173 | + log_file=$(cygpath.exe -u \ |
| 174 | + "${{ steps.bootstrap.outputs.PLEX_PLUGIN_LOG_PATH }}/dev.chazlarson.mediascripts-plex.log") |
| 175 | + else |
| 176 | + log_file="${{ steps.bootstrap.outputs.PLEX_PLUGIN_LOG_PATH }}/dev.chazlarson.mediascripts-plex.log" |
| 177 | + fi |
| 178 | + cat "${log_file}" |
| 179 | +
|
| 180 | + - name: Upload coverage |
| 181 | + # any except canceled or skipped |
| 182 | + if: >- |
| 183 | + always() && |
| 184 | + (steps.test.outcome == 'success' || steps.test.outcome == 'failure') && |
| 185 | + startsWith(github.repository, 'chazlarson/') |
| 186 | + uses: codecov/codecov-action@v4 |
| 187 | + with: |
| 188 | + fail_ci_if_error: true |
| 189 | + flags: ${{ runner.os }} |
| 190 | + token: ${{ secrets.CODECOV_TOKEN }} |
0 commit comments