From d5135cdbb8c07aa899040c1d38ae81cad87cce64 Mon Sep 17 00:00:00 2001 From: Jorge Capona Date: Thu, 25 Jul 2024 14:53:39 -0400 Subject: [PATCH 1/2] Update workflows --- .github/workflows/deb-build.yml | 63 ++++++++++++++++++++---- .github/workflows/deb-release.yml | 79 ++++++++++++++++++++++++++----- 2 files changed, 123 insertions(+), 19 deletions(-) diff --git a/.github/workflows/deb-build.yml b/.github/workflows/deb-build.yml index e839b84..dd77daf 100644 --- a/.github/workflows/deb-build.yml +++ b/.github/workflows/deb-build.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - bullseye workflow_dispatch: env: @@ -14,7 +15,6 @@ env: CHANGELOG_AUTHOR_EMAIL: "deb-maintainers@pi-top.com" PACKAGECLOUD_REPO: "experimental" OS: "debian" - DISTROS: "\"distro\":[\"bookworm\", \"bullseye\"]" HOST_COMPILE: "\"architecture\":[\"amd64\"]" X_COMPILE: "\"architecture\":[\"armhf\", \"arm64\"]" # ARM 32 and 64 bit @@ -22,7 +22,7 @@ jobs: check-architecture: runs-on: ubuntu-20.04 outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + architecture: ${{ steps.set-arch.outputs.architecture }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -30,7 +30,7 @@ jobs: submodules: true - name: Determine target architecture - id: set-matrix + id: set-arch # If any packages define architecture as other than 'all' # then it can't be compiled on host architecture run: | @@ -38,14 +38,58 @@ jobs: if grep '^Architecture:' debian/control | grep -q -v 'all'; then architecture=$X_COMPILE fi - echo "matrix={$architecture, $DISTROS}">>$GITHUB_OUTPUT + + echo "Building for $architecture" + echo "architecture=$architecture">>$GITHUB_OUTPUT + + check-distro: + runs-on: ubuntu-20.04 + outputs: + distros: ${{ steps.set-distros.outputs.distros }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Determine build distro + id: set-distros + run: | + distros="\"distro\":[\"bookworm\", \"bullseye\"]" + + # if bullseye branch exists, build for bookworm only + if git branch -r | grep -Eq "origin/bullseye$"; then + distros="\"distro\":[\"bookworm\"]" + fi + + # if pull request to bullseye branch or current branch is bullseye, build only for bullseye + if [ $(echo ${{ github.head_ref }} | grep -qE "bullseye$") ] || [ ${{ github.ref }} = 'refs/heads/bullseye' ]; then + distros="\"distro\":[\"bullseye\"]" + fi + + echo "Building for $distros" + echo "distros=$distros">>$GITHUB_OUTPUT + + set-build-matrix: + needs: [check-distro, check-architecture] + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Determine build matrix + id: set-matrix + run: | + matrix='{${{needs.check-distro.outputs.distros}}, ${{needs.check-architecture.outputs.architecture}}}' + echo "Building for $matrix" + echo "matrix=$matrix">>$GITHUB_OUTPUT build-debian-package: - needs: check-architecture runs-on: ubuntu-20.04 + needs: set-build-matrix strategy: fail-fast: false - matrix: ${{fromJSON(needs.check-architecture.outputs.matrix)}} + matrix: ${{fromJSON(needs.set-build-matrix.outputs.matrix)}} steps: - name: Checkout code uses: actions/checkout@v3 @@ -116,7 +160,10 @@ jobs: # Only 1 .dsc is required for source so take armhf if there's multiple if: | ( - github.ref == 'refs/heads/master' && + ( + github.ref == 'refs/heads/master' || + github.ref == 'refs/heads/bullseye' + ) && ( matrix.architecture == 'amd64' || matrix.architecture == 'armhf' @@ -131,7 +178,7 @@ jobs: - name: Upload .deb to PackageCloud uses: pi-top/ghaction-packagecloud@main - if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bullseye' with: repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }} files: | diff --git a/.github/workflows/deb-release.yml b/.github/workflows/deb-release.yml index d52dbfb..0dcd1c7 100644 --- a/.github/workflows/deb-release.yml +++ b/.github/workflows/deb-release.yml @@ -2,11 +2,10 @@ name: Create GitHub Release on: workflow_dispatch: - branches: - - master pull_request: branches: - master + - bullseye types: [closed] @@ -15,7 +14,6 @@ env: DEB_BUILD_DOCKER_BRANCH: "master" PACKAGECLOUD_REPO: "pi-top-os-unstable" OS: "debian" - DISTROS: "\"distro\":[\"bookworm\", \"bullseye\"]" HOST_COMPILE: "\"architecture\":[\"amd64\"]" X_COMPILE: "\"architecture\":[\"armhf\", \"arm64\"]" # ARM 32 and 64 bit @@ -23,7 +21,7 @@ jobs: check-architecture: runs-on: ubuntu-20.04 outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} + architecture: ${{ steps.set-arch.outputs.architecture }} steps: - name: Checkout code uses: actions/checkout@v3 @@ -31,7 +29,7 @@ jobs: submodules: true - name: Determine target architecture - id: set-matrix + id: set-arch # If any packages define architecture as other than 'all' # then it can't be compiled on host architecture run: | @@ -39,9 +37,54 @@ jobs: if grep '^Architecture:' debian/control | grep -q -v 'all'; then architecture=$X_COMPILE fi - echo "matrix={$architecture, $DISTROS}">>$GITHUB_OUTPUT + + echo "Building for $architecture" + echo "architecture=$architecture">>$GITHUB_OUTPUT + + check-distro: + runs-on: ubuntu-20.04 + outputs: + distros: ${{ steps.set-distros.outputs.distros }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + + - name: Determine build distro + id: set-distros + run: | + distros="\"distro\":[\"bookworm\", \"bullseye\"]" + + # if bullseye branch exists, build for bookworm only + if git branch -r | grep -Eq "origin/bullseye$"; then + distros="\"distro\":[\"bookworm\"]" + fi + + # if pull request to bullseye branch or current branch is bullseye, build only for bullseye + if [ $(echo ${{ github.head_ref }} | grep -qE "bullseye$") ] || [ ${{ github.ref }} = 'refs/heads/bullseye' ]; then + distros="\"distro\":[\"bullseye\"]" + fi + + echo "Building for $distros" + echo "distros=$distros">>$GITHUB_OUTPUT + + set-build-matrix: + needs: [check-distro, check-architecture] + runs-on: ubuntu-20.04 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Determine build matrix + id: set-matrix + run: | + matrix='{${{needs.check-distro.outputs.distros}}, ${{needs.check-architecture.outputs.architecture}}}' + echo "Building for $matrix" + echo "matrix=$matrix">>$GITHUB_OUTPUT check-versions: + if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && github.head_ref == 'bump-changelog') runs-on: ubuntu-20.04 outputs: CURRENT_VERSION: ${{ steps.current_version.outputs.CURRENT_VERSION }} @@ -75,12 +118,12 @@ jobs: echo "CURRENT_VERSION=${{ env.CURRENT_VERSION }}">>"$GITHUB_OUTPUT" release: - needs: [check-architecture, check-versions] + needs: [set-build-matrix, check-versions] runs-on: ubuntu-20.04 if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged && github.head_ref == 'bump-changelog') strategy: fail-fast: false - matrix: ${{fromJSON(needs.check-architecture.outputs.matrix)}} + matrix: ${{fromJSON(needs.set-build-matrix.outputs.matrix)}} steps: - name: Checkout code uses: actions/checkout@v3 @@ -121,12 +164,14 @@ jobs: # Only 1 .dsc is required for source so take armhf if there's multiple if: | ( - github.ref == 'refs/heads/master' && + ( + github.ref == 'refs/heads/master' || + github.ref == 'refs/heads/bullseye' + ) && ( matrix.architecture == 'amd64' || matrix.architecture == 'armhf' ) - ) with: repository: ${{ env.PACKAGECLOUD_REPO }}/${{ env.OS }}/${{ matrix.distro }} @@ -152,9 +197,21 @@ jobs: ls -l ./artifacts zip ${{ matrix.distro }}-${{ matrix.architecture }}.deb.zip ./artifacts/* + - name: Set release tag + run: | + release_tag="v${{ needs.check-versions.outputs.CURRENT_VERSION }}" + matrix="${{needs.set-build-matrix.outputs.matrix}}" + + # if releasing ONLY for bullseye, prepend 'bullseye' to release tag + if [ ${{ matrix.distro }} = 'bullseye' ] && echo "${matrix}" | grep -qv 'bookworm'; then + release_tag="bullseye-$release_tag" + fi + + echo "RELEASE_TAG=${release_tag}" >> $GITHUB_ENV + - name: Create release and upload package uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.PAT_GITHUB }} file: ./${{ matrix.distro}}-${{ matrix.architecture }}.deb.zip - tag: "v${{ needs.check-versions.outputs.CURRENT_VERSION }}" + tag: ${{ env.RELEASE_TAG }} From 6189d9f33739aaad88afad3c397cf5c64c0c3828 Mon Sep 17 00:00:00 2001 From: Jorge Capona Date: Thu, 25 Jul 2024 16:15:49 -0400 Subject: [PATCH 2/2] Start systemd service after lightdm --- .github/workflows/test-all-commits.yml | 3 ++- debian/pt-web-vnc-desktop.service | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-all-commits.yml b/.github/workflows/test-all-commits.yml index c6a9eea..00b08e0 100644 --- a/.github/workflows/test-all-commits.yml +++ b/.github/workflows/test-all-commits.yml @@ -34,10 +34,11 @@ jobs: coverage xml - name: Upload Python test coverage reports to Codecov - uses: codecov/codecov-action@v3.1.0 + uses: codecov/codecov-action@v4 with: files: ./coverage.xml flags: python-tests env_vars: OS,PYTHON fail_ci_if_error: true verbose: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/debian/pt-web-vnc-desktop.service b/debian/pt-web-vnc-desktop.service index 489d998..8ca16e8 100644 --- a/debian/pt-web-vnc-desktop.service +++ b/debian/pt-web-vnc-desktop.service @@ -1,11 +1,12 @@ [Unit] Description=Shares desktop via VNC & HTTP Documentation=https://knowledgebase.pi-top.com/knowledge +After=lightdm.service [Service] Type=simple RemainAfterExit=yes -Restart=no +Restart=on-failure ExecStart=/usr/bin/pt-web-vnc start --display-id 0 ExecStop=/usr/bin/pt-web-vnc stop --display-id 0