From bb8687a57b1c77c5685e19bf22fa9e8c0dacbc00 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Thu, 15 Feb 2024 08:34:18 +0100 Subject: [PATCH] stash --- .github/workflows/release.yaml | 75 ++++++++++++++++++++++++++++++++++ .github/workflows/test.yaml | 16 +++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index e2f8019a..c05a5279 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -57,3 +57,78 @@ jobs: - name: publish to pypi uses: pypa/gh-action-pypi-publish@release/v1 if: startsWith(github.ref, 'refs/tags/') + + publish-images: + runs-on: ubuntu-22.04 + timeout-minutes: 10 + + strategy: + fail-fast: false + matrix: + include: + - vncserver: tigervnc + - vncserver: turbovnc + + services: + # So that we can test this in PRs/branches + local-registry: + image: registry:2 + ports: + - 5000:5000 + + steps: + - name: Should we push this image to a public registry? + run: | + if [ "${{ startsWith(github.ref, 'refs/tags/') || (github.ref == 'refs/heads/main') }}" = "true" ]; then + echo "REGISTRY=quay.io/" >> $GITHUB_ENV + else + echo "REGISTRY=localhost:5000/" >> $GITHUB_ENV + fi + + - uses: actions/checkout@v4 + + - name: Set up QEMU (for docker buildx) + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx (for multi-arch builds) + uses: docker/setup-buildx-action@v3 + with: + # Allows pushing to registry on localhost:5000 + driver-opts: network=host + + - name: Setup push rights + # This was setup by... + # 1. Creating a [Robot Account](https://quay.io/organization/jupyterhub?tab=robots) in the JupyterHub + # Quay.io org + # 2. Giving it enough permissions to push the image + # 3. Putting the robot account's username and password in GitHub actions environment + if: env.REGISTRY != 'localhost:5000/' + run: | + docker login -u "${{ secrets.QUAY_USERNAME }}" -p "${{ secrets.QUAY_PASSWORD }}" "${{ env.REGISTRY }}" + + # https://github.com/jupyterhub/action-major-minor-tag-calculator + # If this is a tagged build this will return additional parent tags. + # E.g. 1.2.3 is expanded to Docker tags + # [{prefix}:1.2.3, {prefix}:1.2, {prefix}:1, {prefix}:latest] unless + # this is a backported tag in which case the newer tags aren't updated. + # For branches this will return the branch name. + # If GITHUB_TOKEN isn't available (e.g. in PRs) returns no tags []. + - name: Get image tags + id: tags + uses: jupyterhub/action-major-minor-tag-calculator@v3 + with: + githubToken: ${{ secrets.GITHUB_TOKEN }} + prefix: >- + ${{ env.REGISTRY }}jupyterhub/jupyter-remote-desktop-proxy: + defaultTag: "${{ env.REGISTRY }}jupyterhub/jupyter-remote-desktop-proxy:noref" + branchRegex: ^\w[\w-.]*$ + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + # tags parameter must be a string input so convert `gettags` JSON + # array into a comma separated list of tags + tags: ${{ join(fromJson(steps.tags.outputs.tags)) }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 4a66f568..d1b161d4 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,17 +16,29 @@ jobs: container: runs-on: ubuntu-22.04 timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + include: + - vncserver: tigervnc + - vncserver: turbovnc steps: - uses: actions/checkout@v4 - name: Build image run: | - docker build -t jupyter-remote-desktop-proxy . + docker build --build-arg vncserver=${{ matrix.vncserver }} -t jupyter-remote-desktop-proxy . - name: Smoke test image run: | - docker run -d -p 8888:8888 -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy + container_id=$(docker run -d -p 8888:8888 -e JUPYTER_TOKEN=secret jupyter-remote-desktop-proxy) + + # -help flag is only available for TigerVNC, where TurboVNC can't + # print info without returning an error code. + docker exec $container_id vncserver -help || true + docker exec $container_id vncserver -list + sleep 10 curl 'http://localhost:8888/desktop/?token=secret' | grep 'Jupyter Remote Desktop Proxy' # Test if the built JS file is present in the image