From 82212f849491b3ccd2d28adc2b1dca56999ef54f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 15:59:30 +0200 Subject: [PATCH 01/36] ci: add some vertical space for readability --- .github/workflows/integration-test.yaml | 6 ++++++ .github/workflows/unit-test.yaml | 5 +++++ .github/workflows/upgrade-test.yaml | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 75e2f6393..7f62b4e88 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -11,28 +11,34 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.6 + - name: Set BOOTSTRAP_PIP_SPEC value run: | echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV + - name: Build systemd image run: | .github/integration-test.py build-image + - name: Run bootstrap checks run: | python3 -m pip install pytest pytest integration-tests/test_bootstrap.py -s + - name: Run basic tests run: | .github/integration-test.py run-test \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ basic-tests test_hub.py test_proxy.py \ test_install.py test_extensions.py + - name: Run admin tests run: | .github/integration-test.py run-test \ --installer-args "--admin admin:admin" \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ basic-tests test_admin_installer.py \ + - name: Run plugin tests run: | .github/integration-test.py run-test \ diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index ce047fda5..cabd60554 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -12,25 +12,30 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.6 + - name: Install venv, git and setup venv run: | apt-get update --yes && apt-get install --yes python3-venv git python3 -m venv /srv/venv echo '/srv/venv/bin' >> $GITHUB_PATH + - name: Cache pip deps uses: actions/cache@v2 with: path: /srv/venv/ key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('*setup.py', '*dev-requirements.txt') }} + - name: Install Python dependencies run: | python3 -m pip install -U pip==20.0.* python3 -m pip install -r dev-requirements.txt python3 -m pip install -e . pip freeze + - name: Run unit tests run: | pytest --cov=tljh tests/ + - name: Upload code coverage stats run: | codecov diff --git a/.github/workflows/upgrade-test.yaml b/.github/workflows/upgrade-test.yaml index 543a909db..d251703b1 100644 --- a/.github/workflows/upgrade-test.yaml +++ b/.github/workflows/upgrade-test.yaml @@ -12,13 +12,16 @@ jobs: - uses: actions/setup-python@v2 with: python-version: 3.6 + - name: Set BOOTSTRAP_PIP_SPEC value run: | echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV echo $BOOTSTRAP_PIP_SPEC + - name: Build systemd image run: | .github/integration-test.py build-image + - name: Run basic tests run: | .github/integration-test.py run-test \ @@ -26,6 +29,7 @@ jobs: basic-tests test_hub.py test_proxy.py \ test_install.py test_extensions.py \ --upgrade + - name: Run admin tests run: | .github/integration-test.py run-test \ @@ -33,6 +37,7 @@ jobs: --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ basic-tests test_admin_installer.py \ --upgrade + - name: Run plugin tests run: | .github/integration-test.py run-test \ From 08544bc3698ed84e732207dd6c155901f4a3b2a4 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 16:06:54 +0200 Subject: [PATCH 02/36] ci: end script lines without trailing backslash --- .github/workflows/integration-test.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 7f62b4e88..e69d517d3 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -37,11 +37,11 @@ jobs: .github/integration-test.py run-test \ --installer-args "--admin admin:admin" \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_admin_installer.py \ + basic-tests test_admin_installer.py - name: Run plugin tests run: | .github/integration-test.py run-test \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ - plugins test_simplest_plugin.py \ + plugins test_simplest_plugin.py From 6daee0d643bf7e1cab16dba31fca1b9475fdeb8d Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 16:12:30 +0200 Subject: [PATCH 03/36] ci: use pytest flags --color --exit-first --verbose --- .github/integration-test.py | 2 +- .github/workflows/integration-test.yaml | 2 +- .github/workflows/unit-test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/integration-test.py b/.github/integration-test.py index 9ea09a8ae..6ffb5c0dd 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -115,7 +115,7 @@ def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, ins ) run_container_command( test_name, - '/opt/tljh/hub/bin/python3 -m pytest -v {}'.format( + '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes {}'.format( ' '.join([os.path.join('/srv/src/integration-tests/', f) for f in test_files]) ) ) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index e69d517d3..70ff10ede 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -23,7 +23,7 @@ jobs: - name: Run bootstrap checks run: | python3 -m pip install pytest - pytest integration-tests/test_bootstrap.py -s + pytest --verbose --maxfail=2 --color=yes --capture=no integration-tests/test_bootstrap.py - name: Run basic tests run: | diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index cabd60554..523676255 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -34,7 +34,7 @@ jobs: - name: Run unit tests run: | - pytest --cov=tljh tests/ + pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/ - name: Upload code coverage stats run: | From 1f16542e097789bfbd51d17f1b4773a38ea74e20 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 16:30:20 +0200 Subject: [PATCH 04/36] ci: don't run tests unless needed --- .github/workflows/integration-test.yaml | 20 ++++++++++++++++++++ .github/workflows/unit-test.yaml | 20 ++++++++++++++++++++ .github/workflows/upgrade-test.yaml | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 70ff10ede..9e8f940e9 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -1,6 +1,26 @@ +# This is a GitHub workflow defining a set of jobs with a set of steps. +# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions +# +name: Integration tests + on: pull_request: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/integration-test.yaml" push: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/integration-test.yaml" + branches-ignore: + - "dependabot/**" + - "pre-commit-ci-update-config" workflow_dispatch: jobs: diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 523676255..3f85a78fc 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -1,6 +1,26 @@ +# This is a GitHub workflow defining a set of jobs with a set of steps. +# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions +# +name: Unit tests + on: pull_request: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/unit-test.yaml" push: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/unit-test.yaml" + branches-ignore: + - "dependabot/**" + - "pre-commit-ci-update-config" workflow_dispatch: jobs: diff --git a/.github/workflows/upgrade-test.yaml b/.github/workflows/upgrade-test.yaml index d251703b1..13c2fe118 100644 --- a/.github/workflows/upgrade-test.yaml +++ b/.github/workflows/upgrade-test.yaml @@ -1,6 +1,26 @@ +# This is a GitHub workflow defining a set of jobs with a set of steps. +# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions +# +name: Upgrade tests + on: pull_request: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/upgrade-test.yaml" push: + paths-ignore: + - "docs/**" + - "**.md" + - "**.rst" + - ".github/workflows/*" + - "!.github/workflows/upgrade-test.yaml" + branches-ignore: + - "dependabot/**" + - "pre-commit-ci-update-config" workflow_dispatch: jobs: From 1ee39c5c550c06c852e12cc4d2f858ec432b1fb9 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 16:34:32 +0200 Subject: [PATCH 05/36] ci: add echo command for consistency between two workflows --- .github/workflows/integration-test.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 9e8f940e9..d61f12153 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -35,6 +35,7 @@ jobs: - name: Set BOOTSTRAP_PIP_SPEC value run: | echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV + echo $BOOTSTRAP_PIP_SPEC - name: Build systemd image run: | From 8c7c43d6e3f78600c6125c4e092bf65d5e8ed04d Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 17:44:37 +0200 Subject: [PATCH 06/36] docs: convert README.rst to markdown --- README.rst | 60 +++++++++++++++++++++--------------------------------- 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/README.rst b/README.rst index 5f8866fea..f881b9050 100644 --- a/README.rst +++ b/README.rst @@ -1,17 +1,10 @@ -======================= -The Littlest JupyterHub -======================= - -.. image:: https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub.svg?style=shield - :target: https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub -.. image:: https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub/branch/master/graph/badge.svg - :target: https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub -.. image:: https://readthedocs.org/projects/the-littlest-jupyterhub/badge/?version=latest - :target: https://the-littlest-jupyterhub.readthedocs.io -.. image:: https://badges.gitter.im/jupyterhub/jupyterhub.svg - :target: https://gitter.im/jupyterhub/jupyterhub -.. image:: https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter - :target: https://the-littlest-jupyterhub.readthedocs.io/en/latest/contributing/index.html +# The Littlest JupyterHub + +[![](https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub.svg?style=shield)](https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub) +[![](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub/branch/master/graph/badge.svg)](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub) +[![](https://readthedocs.org/projects/the-littlest-jupyterhub/badge/?version=latest)](https://the-littlest-jupyterhub.readthedocs.io) +[![](https://badges.gitter.im/jupyterhub/jupyterhub.svg)](https://gitter.im/jupyterhub/jupyterhub) +[![](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://the-littlest-jupyterhub.readthedocs.io/en/latest/contributing/index.html) **The Littlest JupyterHub** (TLJH) distribution helps you provide Jupyter Notebooks to 1-100 users on a single server. @@ -21,27 +14,24 @@ but would like to provide hosted Jupyter Notebooks for their students or users. All users are provided with the same environment, and administrators can easily install libraries into this environment without any specialized knowledge. -See the `latest documentation `_ +See the [latest documentation](https://the-littlest-jupyterhub.readthedocs.io) for more information on using The Littlest JupyterHub. -For support questions please search or post to `our forum `_. +For support questions please search or post to [our forum](https://discourse.jupyter.org/c/jupyterhub/). -See the `contributing guide `_ +See the [contributing guide](https://the-littlest-jupyterhub.readthedocs.io/en/latest/contributing/index.html) for information on the different ways of contributing to The Littlest JupyterHub. -See `this blog post `_ for +See [this blog post](http://words.yuvi.in/post/the-littlest-jupyterhub/) for more information. - -Development Status -================== +## Development Status This project is currently in **beta** state. Folks have been using installations of TLJH for more than a year now to great success. While we try hard not to, we might still make breaking changes that have no clear upgrade pathway. -Installation -============ +## Installation The Littlest JupyterHub (TLJH) can run on any server that is running at least **Ubuntu 18.04**. Earlier versions of Ubuntu are not supported. @@ -51,21 +41,19 @@ We have several tutorials to get you started. on it. These are **recommended** if you do not have much experience setting up servers. - - `Digital Ocean `_ - - `OVH `_ - - `Google Cloud `_ - - `Jetstream `_ - - `Amazon Web Services `_ - - `Microsoft Azure `_ + - [Digital Ocean](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/digitalocean.html) + - [OVH](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/ovh.html) + - [Google Cloud](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/google.html) + - [Jetstream](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/jetstream.html) + - [Amazon Web Services](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/amazon.html) + - [Microsoft Azure](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/azure.html) - ... your favorite provider here, if you can contribute! -- `Tutorial to install TLJH on an already running server you have root access to - `_. +- [Tutorial to install TLJH on an already running server you have root access to](https://the-littlest-jupyterhub.readthedocs.io/en/latest/install/custom-server.html). You should use this if your cloud provider does not already have a direct tutorial, or if you have experience setting up servers. -Documentation -============= +## Documentation Our latest documentation is at: https://the-littlest-jupyterhub.readthedocs.io @@ -75,7 +63,5 @@ is not documented, it is a bug! We try to treat our documentation like we treat our code: we aim to improve it as often as possible. If something is confusing to you in the documentation, it is a bug. We would be -happy if you could `file an issue -`_ about it - or -even better, `contribute a documentation fix -`_! +happy if you could [file an issue](https://github.com/jupyterhub/the-littlest-jupyterhub/issues) about it - or +even better, [contribute a documentation fix](http://the-littlest-jupyterhub.readthedocs.io/en/latest/contributing/docs.html)! From bc00d4f5c8adf6367741769599b0e8c615497cb3 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 17:45:01 +0200 Subject: [PATCH 07/36] docs: rename README.rst to README.md --- README.rst => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.rst => README.md (100%) diff --git a/README.rst b/README.md similarity index 100% rename from README.rst rename to README.md From 211abb95e12406804f6907efd344c5da8c630036 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sat, 16 Oct 2021 18:12:47 +0200 Subject: [PATCH 08/36] docs: remove circleci badge, add others --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f881b9050..361e8be40 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # The Littlest JupyterHub -[![](https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub.svg?style=shield)](https://circleci.com/gh/jupyterhub/the-littlest-jupyterhub) -[![](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub/branch/master/graph/badge.svg)](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub) -[![](https://readthedocs.org/projects/the-littlest-jupyterhub/badge/?version=latest)](https://the-littlest-jupyterhub.readthedocs.io) -[![](https://badges.gitter.im/jupyterhub/jupyterhub.svg)](https://gitter.im/jupyterhub/jupyterhub) -[![](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://the-littlest-jupyterhub.readthedocs.io/en/latest/contributing/index.html) +[![Documentation build status](https://img.shields.io/readthedocs/the-littlest-jupyterhub?logo=read-the-docs)](https://tljh.jupyter.org/en/latest/?badge=latest) +[![GitHub Workflow Status - Test](https://img.shields.io/github/workflow/status/jupyterhub/the-littlest-jupyterhub/Unit%20tests?logo=github&label=tests)](https://github.com/jupyterhub/the-littlest-jupyterhub/actions) +[![Test coverage of code](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub/branch/master/graph/badge.svg)](https://codecov.io/gh/jupyterhub/the-littlest-jupyterhub) +[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyterhub/the-littlest-jupyterhub/issues) +[![Discourse](https://img.shields.io/badge/help_forum-discourse-blue?logo=discourse)](https://discourse.jupyter.org/c/jupyterhub/tljh) +[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyterhub/jupyterhub) +[![Contribute](https://img.shields.io/badge/I_want_to_contribute!-grey?logo=jupyter)](https://tljh.jupyter.org/en/latest/contributing/index.html) **The Littlest JupyterHub** (TLJH) distribution helps you provide Jupyter Notebooks to 1-100 users on a single server. From f4feaa08b5059ed3dc32738ec6bfc6f7ddfe7fe3 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 01:55:00 +0200 Subject: [PATCH 09/36] ci: coalesce integration-test and upgrade-test into one workflow --- .github/workflows/integration-test.yaml | 66 ++++++++++++++++++++++-- .github/workflows/unit-test.yaml | 2 + .github/workflows/upgrade-test.yaml | 67 ------------------------- 3 files changed, 63 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/upgrade-test.yaml diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index d61f12153..fd20ba572 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -24,8 +24,61 @@ on: workflow_dispatch: jobs: - integration-test: - runs-on: ubuntu-18.04 + + # This job is used as a workaround to a limitation when using a matrix of + # variations that a job should be executed against. The limitation is that a + # matrix once defined can't include any conditions. + # + # What this job does before our real test job with a matrix of variations run, + # is to decide on that matrix of variations a conditional logic of our choice. + # + # For more details, see this excellent stack overflow answer: + # https://stackoverflow.com/a/65434401/2220152 + # + decide-on-test-jobs-to-run: + name: Decide on test jobs to run + runs-on: ubuntu-latest + + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + + steps: + # Currently, this logic filters out a matrix entry equaling a specific git + # reference identified by "dont_run_on_ref". + - name: Decide on test jobs to run + id: set-matrix + run: | + matrix_post_filter=$( + echo "$matrix_include_pre_filter" \ + | yq e --output-format=json '.' - \ + | jq '{"include": map( . | select(.dont_run_on_ref != "${{ github.ref }}" ))}' + ) + echo ::set-output name=matrix::$(echo "$matrix_post_filter") + + echo "The subsequent job's matrix are:" + echo $matrix_post_filter | jq '.' + env: + matrix_include_pre_filter: | + - name: "Int. tests: Ubuntu 18.04, Py 3.6" + runs_on: ubuntu-18.04 + extra_flags: "" + - name: "Int. tests: Ubuntu 20.04, Py 3.9" + runs_on: ubuntu-20.04 + extra_flags: "" + - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" + runs_on: ubuntu-20.04 + extra_flags: --upgrade + dont_run_on_ref: refs/heads/master + + integration-tests: + needs: decide-on-test-jobs-to-run + runs-on: ${{ matrix.runs_on }} + + name: ${{ matrix.name }} + strategy: + fail-fast: false + matrix: ${{ fromJson(needs.decide-on-test-jobs-to-run.outputs.matrix) }} + steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 @@ -51,18 +104,21 @@ jobs: .github/integration-test.py run-test \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ basic-tests test_hub.py test_proxy.py \ - test_install.py test_extensions.py + test_install.py test_extensions.py \ + ${{ matrix.extra_flags }} - name: Run admin tests run: | .github/integration-test.py run-test \ --installer-args "--admin admin:admin" \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_admin_installer.py + basic-tests test_admin_installer.py \ + ${{ matrix.extra_flags }} - name: Run plugin tests run: | .github/integration-test.py run-test \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ - plugins test_simplest_plugin.py + plugins test_simplest_plugin.py \ + ${{ matrix.extra_flags }} diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 3f85a78fc..7f63cd42a 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -25,8 +25,10 @@ on: jobs: unit-test: + name: Unit tests runs-on: ubuntu-18.04 container: ubuntu:18.04 + steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 diff --git a/.github/workflows/upgrade-test.yaml b/.github/workflows/upgrade-test.yaml deleted file mode 100644 index 13c2fe118..000000000 --- a/.github/workflows/upgrade-test.yaml +++ /dev/null @@ -1,67 +0,0 @@ -# This is a GitHub workflow defining a set of jobs with a set of steps. -# ref: https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions -# -name: Upgrade tests - -on: - pull_request: - paths-ignore: - - "docs/**" - - "**.md" - - "**.rst" - - ".github/workflows/*" - - "!.github/workflows/upgrade-test.yaml" - push: - paths-ignore: - - "docs/**" - - "**.md" - - "**.rst" - - ".github/workflows/*" - - "!.github/workflows/upgrade-test.yaml" - branches-ignore: - - "dependabot/**" - - "pre-commit-ci-update-config" - workflow_dispatch: - -jobs: - upgrade-test: - if: ${{ github.ref != 'refs/heads/master' }} - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: 3.6 - - - name: Set BOOTSTRAP_PIP_SPEC value - run: | - echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV - echo $BOOTSTRAP_PIP_SPEC - - - name: Build systemd image - run: | - .github/integration-test.py build-image - - - name: Run basic tests - run: | - .github/integration-test.py run-test \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_hub.py test_proxy.py \ - test_install.py test_extensions.py \ - --upgrade - - - name: Run admin tests - run: | - .github/integration-test.py run-test \ - --installer-args "--admin admin:admin" \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_admin_installer.py \ - --upgrade - - - name: Run plugin tests - run: | - .github/integration-test.py run-test \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ - plugins test_simplest_plugin.py \ - --upgrade From 8635af59de99f58b727163e15cec0c843e9af197 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 02:28:38 +0200 Subject: [PATCH 10/36] ci: run int. tests against py3.6 and py3.9 --- .github/workflows/integration-test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index fd20ba572..d8c39c04d 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -61,12 +61,15 @@ jobs: matrix_include_pre_filter: | - name: "Int. tests: Ubuntu 18.04, Py 3.6" runs_on: ubuntu-18.04 + python_version: 3.6 extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9" runs_on: ubuntu-20.04 + python_version: 3.9 extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" runs_on: ubuntu-20.04 + python_version: 3.9 extra_flags: --upgrade dont_run_on_ref: refs/heads/master @@ -83,7 +86,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: ${{ matrix.python_version }} - name: Set BOOTSTRAP_PIP_SPEC value run: | From 922bfad0f5b6a991e543bfcba7c309d95973862f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 03:31:37 +0200 Subject: [PATCH 11/36] ci: let ubuntu version be configurable --- .github/integration-test.py | 21 +++++++++++++++------ .github/workflows/integration-test.yaml | 10 +++++----- integration-tests/Dockerfile | 3 ++- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/.github/integration-test.py b/.github/integration-test.py index 6ffb5c0dd..cbbffa508 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -4,15 +4,16 @@ import os -def build_systemd_image(image_name, source_path): +def build_systemd_image(image_name, source_path, build_args=None): """ Build docker image with systemd at source_path. Built image is tagged with image_name """ - subprocess.check_call([ - 'docker', 'build', '-t', image_name, source_path - ]) + cmd = ['docker', 'build', '-t', image_name, source_path] + if build_args: + cmd.extend([f"--build-arg={ba}" for ba in build_args]) + subprocess.check_call(cmd) def run_systemd_image(image_name, container_name, bootstrap_pip_spec): @@ -138,13 +139,21 @@ def main(): argparser = argparse.ArgumentParser() subparsers = argparser.add_subparsers(dest='action') - subparsers.add_parser('build-image') + build_image_parser = subparsers.add_parser('build-image') + build_image_parser.add_argument( + "--build-arg", + action="append", + dest="build_args", + ) + subparsers.add_parser('stop-container').add_argument( 'container_name' ) + subparsers.add_parser('start-container').add_argument( 'container_name' ) + run_parser = subparsers.add_parser('run') run_parser.add_argument('container_name') run_parser.add_argument('command') @@ -181,7 +190,7 @@ def main(): elif args.action == 'stop-container': stop_container(args.container_name) elif args.action == 'build-image': - build_systemd_image(image_name, 'integration-tests') + build_systemd_image(image_name, 'integration-tests', args.build_args) if __name__ == '__main__': diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index d8c39c04d..0ce77c37a 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -60,22 +60,22 @@ jobs: env: matrix_include_pre_filter: | - name: "Int. tests: Ubuntu 18.04, Py 3.6" - runs_on: ubuntu-18.04 + ubuntu_version: 18.04 python_version: 3.6 extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9" - runs_on: ubuntu-20.04 + ubuntu_version: 20.04 python_version: 3.9 extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" - runs_on: ubuntu-20.04 + ubuntu_version: 20.04 python_version: 3.9 extra_flags: --upgrade dont_run_on_ref: refs/heads/master integration-tests: needs: decide-on-test-jobs-to-run - runs-on: ${{ matrix.runs_on }} + runs-on: ubuntu-${{ matrix.ubuntu_version }} name: ${{ matrix.name }} strategy: @@ -95,7 +95,7 @@ jobs: - name: Build systemd image run: | - .github/integration-test.py build-image + .github/integration-test.py build-image --build-arg ubuntu_version=${{ matrix.ubuntu_version }} - name: Run bootstrap checks run: | diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile index 897218901..23d40964c 100644 --- a/integration-tests/Dockerfile +++ b/integration-tests/Dockerfile @@ -1,5 +1,6 @@ # Systemd inside a Docker container, for CI only -FROM ubuntu:18.04 +ARG ubuntu_version=20.04 +FROM ubuntu:${ubuntu_version} RUN apt-get update --yes From 403f2cb5cbeab0bd4f67d6b94ca0db39c5fd013e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 03:31:57 +0200 Subject: [PATCH 12/36] ci: dockerfile: apply apt-get best-practices --- integration-tests/Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile index 23d40964c..c4c9ae0db 100644 --- a/integration-tests/Dockerfile +++ b/integration-tests/Dockerfile @@ -2,9 +2,13 @@ ARG ubuntu_version=20.04 FROM ubuntu:${ubuntu_version} -RUN apt-get update --yes - -RUN apt-get install --yes systemd curl git sudo +RUN apt-get update \ + && apt-get install --yes \ + systemd \ + curl \ + git \ + sudo \ + && rm -rf /var/lib/apt/lists/* # Kill all the things we don't need RUN find /etc/systemd/system \ From 8054411e40acea29b794c71fd9b0fd447bf066db Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 05:12:47 +0200 Subject: [PATCH 13/36] ci: dockerfile: avoid being asked question during apt-get --- integration-tests/Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile index c4c9ae0db..004129aea 100644 --- a/integration-tests/Dockerfile +++ b/integration-tests/Dockerfile @@ -2,7 +2,10 @@ ARG ubuntu_version=20.04 FROM ubuntu:${ubuntu_version} -RUN apt-get update \ +# DEBIAN_FRONTEND is set to avoid being asked for input and hang during build: +# https://anonoz.github.io/tech/2020/04/24/docker-build-stuck-tzdata.html +RUN DEBIAN_FRONTEND=noninteractive \ + && apt-get update \ && apt-get install --yes \ systemd \ curl \ From 5d3e3c0f2cbb6eb6668adb8b35f745282cc84f37 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 03:40:31 +0200 Subject: [PATCH 14/36] ci: run unit tests against 18.04-20.04 and py36-py39 --- .github/workflows/unit-test.yaml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 7f63cd42a..df8780ba4 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -24,16 +24,27 @@ on: workflow_dispatch: jobs: - unit-test: - name: Unit tests - runs-on: ubuntu-18.04 - container: ubuntu:18.04 + unit-tests: + name: ${{ matrix.name }} + runs-on: ubuntu-${{ matrix.ubuntu_version }} + container: ubuntu:${{ matrix.ubuntu_version }} + + strategy: + fail-fast: false + matrix: + include: + - name: "Unit tests: Ubuntu 18.04, Py 3.6" + ubuntu_version: 18.04 + python_version: 3.6 + - name: "Unit tests: Ubuntu 20.04, Py 3.9" + ubuntu_version: 20.04 + python_version: 3.9 steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: - python-version: 3.6 + python-version: ${{ matrix.python_version }} - name: Install venv, git and setup venv run: | From fd99caa8fb3323f147a2d9591f8f75d11bf5ced6 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 04:00:28 +0200 Subject: [PATCH 15/36] ci: bust cache based on python version --- .github/workflows/unit-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index df8780ba4..a867762ee 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -56,7 +56,7 @@ jobs: uses: actions/cache@v2 with: path: /srv/venv/ - key: ${{ runner.os }}-pip-dependencies-${{ hashFiles('*setup.py', '*dev-requirements.txt') }} + key: pip-${{ matrix.ubuntu_version }}-${{ matrix.python_version }}-${{ hashFiles('*setup.py', '*dev-requirements.txt') }} - name: Install Python dependencies run: | From 32e50315cef95ef35bcaf0e6d4d5699da8ccaeca Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 15:36:21 +0200 Subject: [PATCH 16/36] docs: update references from circleci to gha --- docs/contributing/tests.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/contributing/tests.rst b/docs/contributing/tests.rst index bbd8f066b..f8b486b30 100644 --- a/docs/contributing/tests.rst +++ b/docs/contributing/tests.rst @@ -20,7 +20,7 @@ that the various components fit together and work as they should. So we write a lot of integration tests, and put in more effort towards them than unit tests. -All integration tests are run on `CircleCI `_ +All integration tests are run in `GitHub Actions `_ for each PR and merge, making sure we don't have broken tests for too long. @@ -39,7 +39,7 @@ You can then run the tests with: .. code-block:: bash - .circleci/integration-test.py run-test + .github/integration-test.py run-test - ```` is an identifier for the tests - you can choose anything you want - ``>`` is list of test files (under ``integration-tests``) that should be run in one go. @@ -48,7 +48,7 @@ For example, to run all the basic tests, you would write: .. code-block:: bash - .circleci/integration-test.py run-test basic-tests \ + .github/integration-test.py run-test basic-tests \ test_hub.py \ test_install.py \ test_extensions.py @@ -61,5 +61,5 @@ parameter: .. code-block:: bash - .circleci/integration-test.py run-test \ + .github/integration-test.py run-test \ --bootstrap-pip-spec="git+https://github.com/your-username/the-littlest-jupyterhub.git@branch-name" From e1b39cc4d3cc1eb69d9d9041b1e9e3956b8c7e9f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 15:46:39 +0200 Subject: [PATCH 17/36] ci: use separate steps for pytest install and run --- .github/workflows/integration-test.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 0ce77c37a..589a2ee82 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -97,9 +97,12 @@ jobs: run: | .github/integration-test.py build-image --build-arg ubuntu_version=${{ matrix.ubuntu_version }} - - name: Run bootstrap checks + - name: Install pytest run: | python3 -m pip install pytest + + - name: Run bootstrap tests + run: | pytest --verbose --maxfail=2 --color=yes --capture=no integration-tests/test_bootstrap.py - name: Run basic tests From 2dfe4b8211ec4bbdb737c9ea18ca787731171697 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 18:36:34 +0200 Subject: [PATCH 18/36] ci: towards testing non-LTS ubuntu versions --- .github/workflows/integration-test.yaml | 64 +++++++++++++++---------- .github/workflows/unit-test.yaml | 46 +++++++++++++----- integration-tests/Dockerfile | 2 +- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 589a2ee82..a126d3a5d 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -60,22 +60,31 @@ jobs: env: matrix_include_pre_filter: | - name: "Int. tests: Ubuntu 18.04, Py 3.6" - ubuntu_version: 18.04 - python_version: 3.6 + ubuntu_version: "18.04" + python_version: "3.6" extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9" - ubuntu_version: 20.04 - python_version: 3.9 + ubuntu_version: "20.04" + python_version: "3.9" extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" - ubuntu_version: 20.04 - python_version: 3.9 + ubuntu_version: "20.04" + python_version: "3.9" extra_flags: --upgrade dont_run_on_ref: refs/heads/master integration-tests: needs: decide-on-test-jobs-to-run - runs-on: ubuntu-${{ matrix.ubuntu_version }} + + # runs-on can only be configured to the LTS releases of ubuntu (18.04, + # 20.04, ...), so if we want to test against the latest non-LTS release, we + # must compromise when configuring runs-on and configure runs-on to be the + # latest LTS release instead. + # + # This can have consequences because actions like actions/setup-python will + # mount cached installations associated with the chosen runs-on environment. + # + runs-on: ${{ format('ubuntu-{0}', matrix.runs_on || matrix.ubuntu_version) }} name: ${{ matrix.name }} strategy: @@ -95,36 +104,39 @@ jobs: - name: Build systemd image run: | - .github/integration-test.py build-image --build-arg ubuntu_version=${{ matrix.ubuntu_version }} + .github/integration-test.py build-image \ + --build-arg "ubuntu_version=${{ matrix.ubuntu_version }}" - name: Install pytest - run: | - python3 -m pip install pytest + run: python3 -m pip install pytest - name: Run bootstrap tests run: | - pytest --verbose --maxfail=2 --color=yes --capture=no integration-tests/test_bootstrap.py + pytest --verbose --maxfail=2 --color=yes --capture=no \ + integration-tests/test_bootstrap.py - name: Run basic tests run: | - .github/integration-test.py run-test \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_hub.py test_proxy.py \ - test_install.py test_extensions.py \ - ${{ matrix.extra_flags }} + .github/integration-test.py run-test basic-tests \ + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ + ${{ matrix.extra_flags }} \ + test_hub.py \ + test_proxy.py \ + test_install.py \ + test_extensions.py - name: Run admin tests run: | - .github/integration-test.py run-test \ - --installer-args "--admin admin:admin" \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - basic-tests test_admin_installer.py \ - ${{ matrix.extra_flags }} + .github/integration-test.py run-test admin-tests \ + --installer-args "--admin admin:admin" \ + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ + ${{ matrix.extra_flags }} \ + test_admin_installer.py - name: Run plugin tests run: | - .github/integration-test.py run-test \ - --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ - --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ - plugins test_simplest_plugin.py \ - ${{ matrix.extra_flags }} + .github/integration-test.py run-test plugin-tests \ + --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ + --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ + ${{ matrix.extra_flags }} \ + test_simplest_plugin.py diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index a867762ee..7be8bc61c 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -26,7 +26,16 @@ on: jobs: unit-tests: name: ${{ matrix.name }} - runs-on: ubuntu-${{ matrix.ubuntu_version }} + + # runs-on can only be configured to the LTS releases of ubuntu (18.04, + # 20.04, ...), so if we want to test against the latest non-LTS release, we + # must compromise when configuring runs-on and configure runs-on to be the + # latest LTS release instead. + # + # This can have consequences because actions like actions/setup-python will + # mount cached installations associated with the chosen runs-on environment. + # + runs-on: ${{ format('ubuntu-{0}', matrix.runs_on || matrix.ubuntu_version) }} container: ubuntu:${{ matrix.ubuntu_version }} strategy: @@ -34,11 +43,11 @@ jobs: matrix: include: - name: "Unit tests: Ubuntu 18.04, Py 3.6" - ubuntu_version: 18.04 - python_version: 3.6 + ubuntu_version: "18.04" + python_version: "3.6" - name: "Unit tests: Ubuntu 20.04, Py 3.9" - ubuntu_version: 20.04 - python_version: 3.9 + ubuntu_version: "20.04" + python_version: "3.9" steps: - uses: actions/checkout@v2 @@ -47,16 +56,31 @@ jobs: python-version: ${{ matrix.python_version }} - name: Install venv, git and setup venv + timeout-minutes: 2 run: | - apt-get update --yes && apt-get install --yes python3-venv git + export DEBIAN_FRONTEND=noninteractive + apt-get update + apt-get install --yes \ + python3-venv \ + git + python3 -m venv /srv/venv echo '/srv/venv/bin' >> $GITHUB_PATH - - name: Cache pip deps + # WARNING: This action loads a cache of pip dependencies based on the + # declared key, and it will save a cache for that key on job + # completion. Make sure to update the key to bust the cache + # properly if you make a change that should influence it. + - name: Load cached Python dependencies uses: actions/cache@v2 with: path: /srv/venv/ - key: pip-${{ matrix.ubuntu_version }}-${{ matrix.python_version }}-${{ hashFiles('*setup.py', '*dev-requirements.txt') }} + key: >- + pip- + ${{ matrix.runs_on }}- + ${{ matrix.ubuntu_version }}- + ${{ matrix.python_version }}- + ${{ hashFiles('setup.py', 'dev-requirements.txt', '.github/workflows/unit-test.yaml') }} - name: Install Python dependencies run: | @@ -66,9 +90,7 @@ jobs: pip freeze - name: Run unit tests - run: | - pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/ + run: pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/ - name: Upload code coverage stats - run: | - codecov + run: codecov diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile index 004129aea..141667045 100644 --- a/integration-tests/Dockerfile +++ b/integration-tests/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:${ubuntu_version} # DEBIAN_FRONTEND is set to avoid being asked for input and hang during build: # https://anonoz.github.io/tech/2020/04/24/docker-build-stuck-tzdata.html -RUN DEBIAN_FRONTEND=noninteractive \ +RUN export DEBIAN_FRONTEND=noninteractive \ && apt-get update \ && apt-get install --yes \ systemd \ From 4042967437404ed35b9f729007a1e77411b7bec3 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 18:43:15 +0200 Subject: [PATCH 19/36] Unpin pip to support 20.04 --- .github/workflows/unit-test.yaml | 2 +- bootstrap/bootstrap.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 7be8bc61c..04cff1b07 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -84,7 +84,7 @@ jobs: - name: Install Python dependencies run: | - python3 -m pip install -U pip==20.0.* + python3 -m pip install -U pip python3 -m pip install -r dev-requirements.txt python3 -m pip install -e . pip freeze diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 4eb718cd3..563138a6b 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -335,7 +335,7 @@ def serve_forever(server): # Upgrade pip logger.info('Upgrading pip...') - run_subprocess([pip_bin, 'install', '--upgrade', 'pip==20.0.*']) + run_subprocess([pip_bin, 'install', '--upgrade', 'pip']) # Install/upgrade TLJH installer From 2b265baa0b82f0c40305d177507750f90845fbac Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 19:43:13 +0200 Subject: [PATCH 20/36] tests: improve test readability by partial string match --- integration-tests/test_bootstrap.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index 4d3aea592..27dd56b74 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -4,7 +4,6 @@ import concurrent.futures import os import subprocess -from textwrap import dedent import time @@ -91,17 +90,7 @@ def test_ubuntu_too_old(): def test_inside_no_systemd_docker(): output = run_bootstrap("plain-docker-test", "ubuntu:18.04") - assert ( - output.stdout.strip() - == dedent( - """ - Systemd is required to run TLJH - Running inside a docker container without systemd isn't supported - We recommend against running a production TLJH instance inside a docker container - For local development, see http://tljh.jupyter.org/en/latest/contributing/dev-setup.html - """ - ).strip() - ) + assert "Systemd is required to run TLJH" in output.stdout assert output.returncode == 1 From 104ffcf8a6940c52bb3df6f8378c1be0acb68483 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 20:06:26 +0200 Subject: [PATCH 21/36] ci: pytest --capture=no for more logs --- .github/integration-test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/integration-test.py b/.github/integration-test.py index cbbffa508..7235e0626 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -116,7 +116,7 @@ def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, ins ) run_container_command( test_name, - '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes {}'.format( + '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes --capture=no {}'.format( ' '.join([os.path.join('/srv/src/integration-tests/', f) for f in test_files]) ) ) From 777c78e0fe885448cab320602fa09e34ea040017 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Sun, 17 Oct 2021 20:23:31 +0200 Subject: [PATCH 22/36] test: document test_bootstrap.py refactoring plan --- integration-tests/test_bootstrap.py | 41 ++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index 27dd56b74..f82fe3d76 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -38,8 +38,36 @@ def get_bootstrap_script_location(container_name, show_progress_page): subprocess.check_call(["docker", "cp", source_path, f"{container_name}:/srv/src"]) return bootstrap_script - -def run_bootstrap(container_name, image, show_progress_page=False): +# FIXME: Refactor this function to easier to understand using the following +# parameters +# +# - param: container_apt_packages +# - param: bootstrap_tljh_source +# - local: copies local tljh repo to container and configures bootstrap to +# install tljh from copied repo +# - github: configures bootstrap to install tljh from the official github repo +# - : configures bootstrap to install tljh from any given remote location +# - param: bootstrap_flags +def run_bootstrap_after_preparing_container(container_name, image, show_progress_page=False): + """ + 1. Stops old container + 2. Starts --detached container + 3. Installs apt packages in container + 4. Two situations + + A) limited test (--show-progress-page=false) + - Copies ./bootstrap/ folder content to container /srv/src + - Runs copied bootstrap/bootstrap.py without flags + + B) full test (--show-progress-page=true) + - Copies ./ folder content to the container /srv/src + - Runs copied bootstrap/bootstrap.py with environment variables + - TLJH_BOOTSTRAP_DEV=yes + This makes --editable be used when installing the tljh package + - TLJH_BOOTSTRAP_PIP_SPEC=/srv/src + This makes us install tljh from the given location instead of from + github.com/jupyterhub/the-littlest-jupyterhub + """ # stop container if it is already running subprocess.run(["docker", "rm", "-f", container_name]) @@ -49,8 +77,7 @@ def run_bootstrap(container_name, image, show_progress_page=False): "docker", "run", "--detach", - "--name", - container_name, + f"--name={container_name}", image, "/bin/bash", "-c", @@ -83,13 +110,13 @@ def test_ubuntu_too_old(): """ Error with a useful message when running in older Ubuntu """ - output = run_bootstrap("old-distro-test", "ubuntu:16.04") + output = run_bootstrap_after_preparing_container("old-distro-test", "ubuntu:16.04") assert output.stdout == "The Littlest JupyterHub requires Ubuntu 18.04 or higher\n" assert output.returncode == 1 def test_inside_no_systemd_docker(): - output = run_bootstrap("plain-docker-test", "ubuntu:18.04") + output = run_bootstrap_after_preparing_container("plain-docker-test", "ubuntu:18.04") assert "Systemd is required to run TLJH" in output.stdout assert output.returncode == 1 @@ -122,7 +149,7 @@ def verify_progress_page(expected_status_code, timeout): def test_progress_page(): with concurrent.futures.ThreadPoolExecutor() as executor: installer = executor.submit( - run_bootstrap, "progress-page", "ubuntu:18.04", True + run_bootstrap_after_preparing_container, "progress-page", "ubuntu:18.04", True ) # Check if progress page started From a4768226eeb2ac56996432ae176967dcd9a7f52e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 02:05:44 +0200 Subject: [PATCH 23/36] ci: make pytest report time per test --- .github/integration-test.py | 2 +- .github/workflows/integration-test.yaml | 2 +- .github/workflows/unit-test.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/integration-test.py b/.github/integration-test.py index 7235e0626..ab6f83e13 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -116,7 +116,7 @@ def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, ins ) run_container_command( test_name, - '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes --capture=no {}'.format( + '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no {}'.format( ' '.join([os.path.join('/srv/src/integration-tests/', f) for f in test_files]) ) ) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index a126d3a5d..8afa2affc 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -112,7 +112,7 @@ jobs: - name: Run bootstrap tests run: | - pytest --verbose --maxfail=2 --color=yes --capture=no \ + pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ integration-tests/test_bootstrap.py - name: Run basic tests diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 04cff1b07..89e166ca7 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -90,7 +90,7 @@ jobs: pip freeze - name: Run unit tests - run: pytest --verbose --maxfail=2 --color=yes --cov=tljh tests/ + run: pytest --verbose --maxfail=2 --color=yes --durations=10 --cov=tljh tests/ - name: Upload code coverage stats run: codecov From 513aff110280751c9571a5f211a54bb6a0a73846 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 02:54:49 +0200 Subject: [PATCH 24/36] ci: Dockerfile: /lib/systemd/systemd instead of /sbin/init --- integration-tests/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/Dockerfile b/integration-tests/Dockerfile index 141667045..64d5d0b68 100644 --- a/integration-tests/Dockerfile +++ b/integration-tests/Dockerfile @@ -33,4 +33,4 @@ STOPSIGNAL SIGRTMIN+3 #ENV TLJH_BOOTSTRAP_PIP_SPEC=/srv/src #ENV PATH=/opt/tljh/hub/bin:${PATH} -CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"] +CMD ["/bin/bash", "-c", "exec /lib/systemd/systemd --log-target=journal 3>&1"] From 96c3e6fb9305c0e2561950ecb386cfa507e56228 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 03:18:51 +0200 Subject: [PATCH 25/36] ci: add debugging message --- .github/integration-test.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/integration-test.py b/.github/integration-test.py index ab6f83e13..e473d970c 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -95,6 +95,10 @@ def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, ins copy_to_container(test_name, os.path.join(source_path, 'bootstrap/.'), '/srv/src') copy_to_container(test_name, os.path.join(source_path, 'integration-tests/'), '/srv/src') + # These logs can be very relevant to debug a container startup failure + print(f"--- Start of logs from the container: {test_name}") + print(subprocess.check_output(['docker', 'logs', test_name]).decode()) + print(f"--- End of logs from the container: {test_name}") # Install TLJH from the default branch first to test upgrades if upgrade: From 69f2b0b504a108f6dcae7fa761ee4d5ca5424675 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 03:37:21 +0200 Subject: [PATCH 26/36] ci: test against 21.10 --- .github/workflows/integration-test.yaml | 5 +++++ .github/workflows/unit-test.yaml | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 8afa2affc..7f551bd9f 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -67,6 +67,11 @@ jobs: ubuntu_version: "20.04" python_version: "3.9" extra_flags: "" + - name: "Int. tests: Ubuntu 21.10, Py 3.9" + runs_on: "20.04" + ubuntu_version: "21.10" + python_version: "3.9" + extra_flags: "" - name: "Int. tests: Ubuntu 20.04, Py 3.9, --upgrade" ubuntu_version: "20.04" python_version: "3.9" diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 89e166ca7..d1b9d9d7c 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -48,6 +48,10 @@ jobs: - name: "Unit tests: Ubuntu 20.04, Py 3.9" ubuntu_version: "20.04" python_version: "3.9" + - name: "Unit tests: Ubuntu 21.10, Py 3.9" + runs_on: "20.04" + ubuntu_version: "21.10" + python_version: "3.9" steps: - uses: actions/checkout@v2 From fe8ba1596d7baf344bbacabfa44e75480758c7fc Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 04:27:19 +0200 Subject: [PATCH 27/36] ci: fix missing test reference in docs --- docs/contributing/tests.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/contributing/tests.rst b/docs/contributing/tests.rst index f8b486b30..f093ef412 100644 --- a/docs/contributing/tests.rst +++ b/docs/contributing/tests.rst @@ -49,9 +49,10 @@ For example, to run all the basic tests, you would write: .. code-block:: bash .github/integration-test.py run-test basic-tests \ - test_hub.py \ - test_install.py \ - test_extensions.py + test_hub.py \ + test_proxy.py \ + test_install.py \ + test_extensions.py This will run the tests in the three files against the same installation of TLJH and report errors. From 5b820bc85553fab80e968b06568600eb972f264a Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 04:45:33 +0200 Subject: [PATCH 28/36] ci: provide a timeout to ensure logs are collected --- .github/workflows/integration-test.yaml | 4 ++++ .github/workflows/unit-test.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 7f551bd9f..d68622178 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -119,6 +119,7 @@ jobs: run: | pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ integration-tests/test_bootstrap.py + timeout-minutes: 15 - name: Run basic tests run: | @@ -129,6 +130,7 @@ jobs: test_proxy.py \ test_install.py \ test_extensions.py + timeout-minutes: 15 - name: Run admin tests run: | @@ -137,6 +139,7 @@ jobs: --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ ${{ matrix.extra_flags }} \ test_admin_installer.py + timeout-minutes: 15 - name: Run plugin tests run: | @@ -145,3 +148,4 @@ jobs: --installer-args "--plugin /srv/src/integration-tests/plugins/simplest" \ ${{ matrix.extra_flags }} \ test_simplest_plugin.py + timeout-minutes: 15 diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index d1b9d9d7c..31ed95c73 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -60,7 +60,6 @@ jobs: python-version: ${{ matrix.python_version }} - name: Install venv, git and setup venv - timeout-minutes: 2 run: | export DEBIAN_FRONTEND=noninteractive apt-get update @@ -95,6 +94,7 @@ jobs: - name: Run unit tests run: pytest --verbose --maxfail=2 --color=yes --durations=10 --cov=tljh tests/ + timeout-minutes: 15 - name: Upload code coverage stats run: codecov From 1fb43c4b3b57d2d9b348817d6eec86d63de72386 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 04:47:06 +0200 Subject: [PATCH 29/36] Bump jupyterhub-traefik-proxy to 0.3.* --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f73290c0f..00d7402e6 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ 'backoff', 'requests', 'bcrypt', - 'jupyterhub-traefik-proxy==0.2.*', + 'jupyterhub-traefik-proxy==0.3.*', ], entry_points={ 'console_scripts': [ From 1d6ac291455948589a0c6cc571f3ed6b680574f8 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 19:47:48 +0200 Subject: [PATCH 30/36] ci: add notes about pytest --maxfail=2 choice --- .github/integration-test.py | 3 +++ .github/workflows/integration-test.yaml | 3 +++ .github/workflows/unit-test.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/integration-test.py b/.github/integration-test.py index e473d970c..67b8a9d3a 100755 --- a/.github/integration-test.py +++ b/.github/integration-test.py @@ -120,6 +120,9 @@ def run_test(image_name, test_name, bootstrap_pip_spec, test_files, upgrade, ins ) run_container_command( test_name, + # We abort pytest after two failures as a compromise between wanting to + # avoid a flood of logs while still understanding if multiple tests + # would fail. '/opt/tljh/hub/bin/python3 -m pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no {}'.format( ' '.join([os.path.join('/srv/src/integration-tests/', f) for f in test_files]) ) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index d68622178..31c699878 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -115,6 +115,9 @@ jobs: - name: Install pytest run: python3 -m pip install pytest + # We abort pytest after two failures as a compromise between wanting to + # avoid a flood of logs while still understanding if multiple tests would + # fail. - name: Run bootstrap tests run: | pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 31ed95c73..2c44b1537 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -92,6 +92,9 @@ jobs: python3 -m pip install -e . pip freeze + # We abort pytest after two failures as a compromise between wanting to + # avoid a flood of logs while still understanding if multiple tests would + # fail. - name: Run unit tests run: pytest --verbose --maxfail=2 --color=yes --durations=10 --cov=tljh tests/ timeout-minutes: 15 From ba25e09b829b94cbbe409032af7140dab5cf5881 Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 19:56:15 +0200 Subject: [PATCH 31/36] Pin pip to 21.3.* --- .github/workflows/unit-test.yaml | 4 +++- bootstrap/bootstrap.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index 2c44b1537..c01c91091 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -86,8 +86,10 @@ jobs: ${{ hashFiles('setup.py', 'dev-requirements.txt', '.github/workflows/unit-test.yaml') }} - name: Install Python dependencies + # Keep pip version pinning in sync with the one in bootstrap.py! + # See changelog at https://pip.pypa.io/en/latest/news/#changelog run: | - python3 -m pip install -U pip + python3 -m pip install -U "pip==21.3.*" python3 -m pip install -r dev-requirements.txt python3 -m pip install -e . pip freeze diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index 563138a6b..dc1309f50 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -334,8 +334,10 @@ def serve_forever(server): # Upgrade pip + # Keep pip version pinning in sync with the one in unit-test.yml! + # See changelog at https://pip.pypa.io/en/latest/news/#changelog logger.info('Upgrading pip...') - run_subprocess([pip_bin, 'install', '--upgrade', 'pip']) + run_subprocess([pip_bin, 'install', '--upgrade', 'pip==21.3.*']) # Install/upgrade TLJH installer From 6531f79371c0fc8103e4a21a3b1ca70ae23feb3e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Mon, 18 Oct 2021 20:32:27 +0200 Subject: [PATCH 32/36] ci: Disable unit tests against 21.10 --- .github/workflows/unit-test.yaml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml index c01c91091..5de90ce1f 100644 --- a/.github/workflows/unit-test.yaml +++ b/.github/workflows/unit-test.yaml @@ -48,10 +48,13 @@ jobs: - name: "Unit tests: Ubuntu 20.04, Py 3.9" ubuntu_version: "20.04" python_version: "3.9" - - name: "Unit tests: Ubuntu 21.10, Py 3.9" - runs_on: "20.04" - ubuntu_version: "21.10" - python_version: "3.9" + # Test against Ubuntu 21.10 fails as of 2021-10-18 fail with the error + # described in: https://github.com/jupyterhub/the-littlest-jupyterhub/issues/714#issuecomment-945154101 + # + # - name: "Unit tests: Ubuntu 21.10, Py 3.9" + # runs_on: "20.04" + # ubuntu_version: "21.10" + # python_version: "3.9" steps: - uses: actions/checkout@v2 From 26c34524b2eae066435bfb791ef035eb2320862f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Tue, 19 Oct 2021 15:18:02 +0200 Subject: [PATCH 33/36] bootstrap: DEBIAN_FRONTEND=noninteractive during apt-get install --- bootstrap/bootstrap.py | 31 +++++++++++++++-------------- integration-tests/test_bootstrap.py | 1 + 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index dc1309f50..e66fcb62b 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -311,22 +311,23 @@ def serve_forever(server): logger.info('Existing TLJH installation not detected, installing...') logger.info('Setting up hub environment...') logger.info('Installing Python, venv, pip, and git via apt-get...') - # Install software-properties-common, so we can get add-apt-repository - # That helps us make sure the universe repository is enabled, since - # that's where the python3-pip package lives. In some very minimal base - # VM images, it looks like the universe repository is disabled by default, - # causing bootstrapping to fail. - run_subprocess(['apt-get', 'update', '--yes']) - run_subprocess(['apt-get', 'install', '--yes', 'software-properties-common']) - run_subprocess(['add-apt-repository', 'universe']) - run_subprocess(['apt-get', 'update', '--yes']) - run_subprocess(['apt-get', 'install', '--yes', - 'python3', - 'python3-venv', - 'python3-pip', - 'git' - ]) + # In some very minimal base VM images, it looks like the "universe" apt + # package repository is disabled by default, causing bootstrapping to + # fail. We install the software-properties-common package so we can get + # the add-apt-repository command to make sure the universe repository is + # enabled, since that's where the python3-pip package lives. + # + # In Ubuntu 21.10 DEBIAN_FRONTEND has found to be needed to avoid + # getting stuck on an input prompt during apt-get install. + # + apt_get_adjusted_env = os.environ.copy() + apt_get_adjusted_env["DEBIAN_FRONTEND"] = "noninteractive" + run_subprocess(['apt-get', 'update']) + run_subprocess(['apt-get', 'install', '--yes', 'software-properties-common'], env=apt_get_adjusted_env) + run_subprocess(['add-apt-repository', 'universe']) + run_subprocess(['apt-get', 'update']) + run_subprocess(['apt-get', 'install', '--yes', 'python3', 'python3-venv', 'python3-pip', 'git'], env=apt_get_adjusted_env) logger.info('Setting up virtual environment at {}'.format(hub_prefix)) os.makedirs(hub_prefix, exist_ok=True) diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index f82fe3d76..76d02a456 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -76,6 +76,7 @@ def run_bootstrap_after_preparing_container(container_name, image, show_progress [ "docker", "run", + "--env=DEBIAN_FRONTEND=noninteractive", "--detach", f"--name={container_name}", image, From 3596039bbdf62b3f73825da1ff01f00878c9d22e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 20 Oct 2021 10:24:47 +0200 Subject: [PATCH 34/36] ci: ensure to --yes adding apt-get repository --- bootstrap/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap/bootstrap.py b/bootstrap/bootstrap.py index e66fcb62b..23739df5b 100644 --- a/bootstrap/bootstrap.py +++ b/bootstrap/bootstrap.py @@ -325,7 +325,7 @@ def serve_forever(server): apt_get_adjusted_env["DEBIAN_FRONTEND"] = "noninteractive" run_subprocess(['apt-get', 'update']) run_subprocess(['apt-get', 'install', '--yes', 'software-properties-common'], env=apt_get_adjusted_env) - run_subprocess(['add-apt-repository', 'universe']) + run_subprocess(['add-apt-repository', 'universe', '--yes']) run_subprocess(['apt-get', 'update']) run_subprocess(['apt-get', 'install', '--yes', 'python3', 'python3-venv', 'python3-pip', 'git'], env=apt_get_adjusted_env) From 4a8308b0db743d8e3dcae9ef6c287ac82792f92f Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 20 Oct 2021 11:20:19 +0200 Subject: [PATCH 35/36] ci: ensure all tests adjust based on matrix.ubuntu_version --- .github/workflows/integration-test.yaml | 6 ++++++ integration-tests/test_bootstrap.py | 10 ++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 31c699878..1ff559161 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -123,6 +123,12 @@ jobs: pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ integration-tests/test_bootstrap.py timeout-minutes: 15 + env: + # integration-tests/test_bootstrap.py will build and start containers + # based on this environment variable. This is similar to how + # .github/integration-test.py build-image can take a --build-arg + # setting the ubuntu_version. + UBUNTU_VERSION: ${{ matrix.ubuntu_version }} - name: Run basic tests run: | diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index 76d02a456..8af432931 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -117,7 +117,10 @@ def test_ubuntu_too_old(): def test_inside_no_systemd_docker(): - output = run_bootstrap_after_preparing_container("plain-docker-test", "ubuntu:18.04") + output = run_bootstrap_after_preparing_container( + "plain-docker-test", + f"ubuntu:{os.getenv('UBUNTU_VERSION', '20.04')}", + ) assert "Systemd is required to run TLJH" in output.stdout assert output.returncode == 1 @@ -150,7 +153,10 @@ def verify_progress_page(expected_status_code, timeout): def test_progress_page(): with concurrent.futures.ThreadPoolExecutor() as executor: installer = executor.submit( - run_bootstrap_after_preparing_container, "progress-page", "ubuntu:18.04", True + run_bootstrap_after_preparing_container, + "progress-page", + f"ubuntu:{os.getenv('UBUNTU_VERSION', '20.04')}", + True ) # Check if progress page started From 6cb3172b93ba42d59c2b067a01cfdb02ba2b2d5e Mon Sep 17 00:00:00 2001 From: Erik Sundell Date: Wed, 20 Oct 2021 11:21:34 +0200 Subject: [PATCH 36/36] ci: add fixme statements and organize for comprehension --- .github/workflows/integration-test.yaml | 50 ++++++++++++++++++------- integration-tests/test_bootstrap.py | 7 ++++ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/integration-test.yaml b/.github/workflows/integration-test.yaml index 1ff559161..cd910a455 100644 --- a/.github/workflows/integration-test.yaml +++ b/.github/workflows/integration-test.yaml @@ -102,23 +102,13 @@ jobs: with: python-version: ${{ matrix.python_version }} - - name: Set BOOTSTRAP_PIP_SPEC value - run: | - echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV - echo $BOOTSTRAP_PIP_SPEC - - - name: Build systemd image - run: | - .github/integration-test.py build-image \ - --build-arg "ubuntu_version=${{ matrix.ubuntu_version }}" - - name: Install pytest run: python3 -m pip install pytest # We abort pytest after two failures as a compromise between wanting to # avoid a flood of logs while still understanding if multiple tests would # fail. - - name: Run bootstrap tests + - name: Run bootstrap tests (Runs in/Builds ubuntu:${{ matrix.ubuntu_version }} derived image) run: | pytest --verbose --maxfail=2 --color=yes --durations=10 --capture=no \ integration-tests/test_bootstrap.py @@ -130,7 +120,39 @@ jobs: # setting the ubuntu_version. UBUNTU_VERSION: ${{ matrix.ubuntu_version }} - - name: Run basic tests + # We build a docker image from wherein we will work + - name: Build systemd image (Builds ubuntu:${{ matrix.ubuntu_version }} derived image) + run: | + .github/integration-test.py build-image \ + --build-arg "ubuntu_version=${{ matrix.ubuntu_version }}" + + # FIXME: Make the logic below easier to follow. + # - In short, setting BOOTSTRAP_PIP_SPEC here, specifies from what + # location the tljh python package should be installed from. In this + # GitHub Workflow's test job, we provide a remote reference to itself as + # found on GitHub - this could be the HEAD of a PR branch or the default + # branch on merge. + # + # Overview of how this logic influences the end result. + # - integration-test.yaml: + # Runs integration-test.py by passing --bootstrap-pip-spec flag with a + # reference to the pull request on GitHub. + # - integration-test.py: + # Starts a pre-build systemd container, setting the + # TLJH_BOOTSTRAP_PIP_SPEC based on its passed --bootstrap-pip-spec value. + # - systemd container: + # Runs bootstrap.py + # - bootstrap.py + # Makes use of TLJH_BOOTSTRAP_PIP_SPEC environment variable to install + # the tljh package from a given location, which could be a local git + # clone of this repo where setup.py resides, or a reference to some + # GitHub branch for example. + - name: Set BOOTSTRAP_PIP_SPEC value + run: | + echo "BOOTSTRAP_PIP_SPEC=git+https://github.com/$GITHUB_REPOSITORY.git@$GITHUB_REF" >> $GITHUB_ENV + echo $BOOTSTRAP_PIP_SPEC + + - name: Run basic tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) run: | .github/integration-test.py run-test basic-tests \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ @@ -141,7 +163,7 @@ jobs: test_extensions.py timeout-minutes: 15 - - name: Run admin tests + - name: Run admin tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) run: | .github/integration-test.py run-test admin-tests \ --installer-args "--admin admin:admin" \ @@ -150,7 +172,7 @@ jobs: test_admin_installer.py timeout-minutes: 15 - - name: Run plugin tests + - name: Run plugin tests (Runs in ubuntu:${{ matrix.ubuntu_version }} derived image) run: | .github/integration-test.py run-test plugin-tests \ --bootstrap-pip-spec "$BOOTSTRAP_PIP_SPEC" \ diff --git a/integration-tests/test_bootstrap.py b/integration-tests/test_bootstrap.py index 8af432931..de95a46bb 100644 --- a/integration-tests/test_bootstrap.py +++ b/integration-tests/test_bootstrap.py @@ -48,6 +48,13 @@ def get_bootstrap_script_location(container_name, show_progress_page): # - github: configures bootstrap to install tljh from the official github repo # - : configures bootstrap to install tljh from any given remote location # - param: bootstrap_flags +# +# FIXME: Consider stripping logic in this file to only testing if the bootstrap +# script successfully detects the too old Ubuntu version and the lack of +# systemd. The remaining test named test_progress_page could rely on +# running against the systemd container that cab be built by +# integration-test.py. +# def run_bootstrap_after_preparing_container(container_name, image, show_progress_page=False): """ 1. Stops old container