From 21ccbddc495acf861af9a2264cebcc6baef47555 Mon Sep 17 00:00:00 2001 From: Jan-Benedikt Jagusch Date: Sat, 18 Feb 2023 19:44:05 +0100 Subject: [PATCH] Add prettier pre-commit hook (#608) * Add prettier pre-commit hook. * Update lint CI workflow. * Add .env and .envrc to gitignore. * Satify prettier. * Specify prettier version. --- .github/workflows/ci.yml | 2 +- .github/workflows/docker-build-push.yml | 2 +- .github/workflows/lint.yml | 4 +- .github/workflows/sphinx.yml | 5 +- .gitignore | 5 +- .pre-commit-config.yaml | 4 + CONTRIBUTING.md | 10 +- README.md | 30 +-- RELEASE.md | 2 +- docker-compose.yml | 31 ++- docker/prometheus.yml | 6 +- environment.yml | 2 +- .../tests/data/key_mgr.json | 2 +- .../quetz_content_trust/tests/data/root.json | 2 +- plugins/quetz_repodata_patching/README.md | 3 +- plugins/quetz_runexports/README.md | 3 +- plugins/quetz_sql_authenticator/README.md | 2 +- plugins/quetz_transmutation/README.md | 1 - quetz/basic_frontend/index.html | 191 ++++++++++-------- 19 files changed, 172 insertions(+), 135 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b99b479..3ed967fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -107,7 +107,7 @@ jobs: echo "adding micromamba to path: $MAMBA_EXE" pip install --no-deps git+https://git@github.com/regro/libcflib@master - + for f in ./plugins/quetz_* do echo "::group::Testing plugin ${f}" diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index be6a63a6..f5f20a92 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -5,7 +5,7 @@ on: branches: - main tags: - - '**' + - "**" jobs: docker: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b7e0d1ce..9f6763b1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,7 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 + - uses: mamba-org/provision-with-micromamba@v15 - uses: pre-commit/action@v2.0.0 with: extra_args: --all-files --show-diff-on-failure + env: + PRE_COMMIT_USE_MICROMAMBA: 1 diff --git a/.github/workflows/sphinx.yml b/.github/workflows/sphinx.yml index 10c5a18f..63160c78 100644 --- a/.github/workflows/sphinx.yml +++ b/.github/workflows/sphinx.yml @@ -3,10 +3,10 @@ name: "sphinx docs check" on: push: branches: - - main + - main pull_request: branches: - - main + - main jobs: docs: @@ -27,4 +27,3 @@ jobs: with: name: DocumentationHTML path: docs/build/html - diff --git a/.gitignore b/.gitignore index 28c1ad4c..eb14879b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,7 @@ test_quetz # IDE .idea/ -.vscode/ \ No newline at end of file +.vscode/ + +.env +.envrc diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8ea08c40..944084bf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -32,3 +32,7 @@ repos: - types-toml - types-ujson args: [--show-error-codes] + - repo: https://github.com/Quantco/pre-commit-mirrors-prettier + rev: 2.7.1 + hooks: + - id: prettier-conda diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7abe43bf..ffc19910 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,8 +26,8 @@ formatting checks prior to making a commit. Make sure to include the following with your pull requests: -* description, -* links to relevant issues, -* any necessary code changes, -* unit tests for these changes, -* changes to relevant documentation sections +- description, +- links to relevant issues, +- any necessary code changes, +- unit tests for these changes, +- changes to relevant documentation sections diff --git a/README.md b/README.md index d541e395..1895fcad 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,9 @@ quetz run test_quetz --copy-conf ./dev_config.toml --dev --reload Links: -* - Login with your github account -* - Login with test user, one of [alice | bob | carol | dave] -* - Swagger UI for this REST service +- - Login with your github account +- - Login with test user, one of [alice | bob | carol | dave] +- - Swagger UI for this REST service Download `xtensor` as test package: @@ -191,7 +191,7 @@ Finally, you can create and run a new quetz deployment based on this configurati quetz run postgres_quetz --copy-conf config_postgres.toml ``` -Note that this recipe will create an ephemeral PostgreSQL database and it will delete all data after the `some-postgres` container is stopped and removed. To make the data persistent, please check the documentation of the `postgres` [image](https://hub.docker.com/_/postgres/) or your container orchestration system (Kubernetes or similar). +Note that this recipe will create an ephemeral PostgreSQL database and it will delete all data after the `some-postgres` container is stopped and removed. To make the data persistent, please check the documentation of the `postgres` [image](https://hub.docker.com/_/postgres/) or your container orchestration system (Kubernetes or similar). ### Running tests with PostgreSQL backend @@ -258,17 +258,17 @@ In order to generate an API key the following must be true: 2. The user must be part of the target channel (you might need to create a channel first, see the previous section on how to create a channel via the swagger docs) 3. Go to the swagger docs at `:/docs` and POST to `/api/api-keys`: - ```json - { - "description": "my-test-token", - "roles": [ - { - "role": "owner", - "channel": "my-channel" - } - ] - } - ``` + ```json + { + "description": "my-test-token", + "roles": [ + { + "role": "owner", + "channel": "my-channel" + } + ] + } + ``` 4. Then, GET on `/api/api-keys` to retrieve your token 5. Finally, set this value to QUETZ_API_KEY so you can use quetz-client to interact with the server. diff --git a/RELEASE.md b/RELEASE.md index 7593b57b..b8d11778 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -15,7 +15,7 @@ Python package. Before generating a package, we first need to install `build`. pip install build twine ``` -To create a Python source package (``.tar.gz``) and the binary package (`.whl`) in the `dist/` directory, do: +To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do: ```bash python -m build diff --git a/docker-compose.yml b/docker-compose.yml index cd52aa0a..715c7467 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3' +version: "3" services: web: @@ -6,43 +6,53 @@ services: container_name: quetz-web ports: - "8000:8000" - build: + build: context: . dockerfile: ./docker/Dockerfile environment: - HTTPX_LOG_LEVEL=TRACE - command: ["sh", "-c", "./docker/wait-for-postgres.sh database && quetz start /quetz-deployment --host 0.0.0.0 --port 8000 --reload"] - depends_on: + command: + [ + "sh", + "-c", + "./docker/wait-for-postgres.sh database && quetz start /quetz-deployment --host 0.0.0.0 --port 8000 --reload", + ] + depends_on: - database - init-db volumes: - .:/code - quetz_deployment:/quetz-deployment env_file: - - docker/postgres.env + - docker/postgres.env init-db: image: quetz_dev_image - command: ["sh", "-c", "./docker/wait-for-postgres.sh database && quetz create /quetz-deployment --copy-conf /code/docker/docker_config.toml --exists-ok && quetz init-db /quetz-deployment"] - depends_on: + command: + [ + "sh", + "-c", + "./docker/wait-for-postgres.sh database && quetz create /quetz-deployment --copy-conf /code/docker/docker_config.toml --exists-ok && quetz init-db /quetz-deployment", + ] + depends_on: - database volumes: - .:/code - quetz_deployment:/quetz-deployment env_file: - - docker/postgres.env + - docker/postgres.env database: image: postgres volumes: - ./docker/postgres.conf:/etc/postgresql/postgresql.conf env_file: - - docker/postgres.env + - docker/postgres.env prometheus: image: prom/prometheus volumes: - ./docker/prometheus.yml:/etc/prometheus/prometheus.yml grafana: image: grafana/grafana - ports: + ports: - 3000:3000 volumes: - ./docker/graphana_datasources.yml:/etc/grafana/provisioning/datasources/datasource.yaml @@ -69,4 +79,3 @@ services: volumes: quetz_deployment: - diff --git a/docker/prometheus.yml b/docker/prometheus.yml index 6471ed04..da9907e5 100644 --- a/docker/prometheus.yml +++ b/docker/prometheus.yml @@ -1,14 +1,14 @@ global: - scrape_interval: 15s # By default, scrape targets every 15 seconds. + scrape_interval: 15s # By default, scrape targets every 15 seconds. # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself. scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - - job_name: 'quetz' + - job_name: "quetz" metrics_path: /metricsp # Override the global default and scrape targets from this job every 5 seconds. scrape_interval: 5s static_configs: - - targets: ['web:8000'] + - targets: ["web:8000"] diff --git a/environment.yml b/environment.yml index 8c1a3712..4fc0e755 100644 --- a/environment.yml +++ b/environment.yml @@ -42,4 +42,4 @@ dependencies: - importlib_metadata - pre-commit - pip: - - git+https://github.com/jupyter-server/jupyter_releaser.git@v2 + - git+https://github.com/jupyter-server/jupyter_releaser.git@v2 diff --git a/plugins/quetz_content_trust/tests/data/key_mgr.json b/plugins/quetz_content_trust/tests/data/key_mgr.json index 58fe237c..31051818 100644 --- a/plugins/quetz_content_trust/tests/data/key_mgr.json +++ b/plugins/quetz_content_trust/tests/data/key_mgr.json @@ -19,4 +19,4 @@ "type": "key_mgr", "version": 1 } -} \ No newline at end of file +} diff --git a/plugins/quetz_content_trust/tests/data/root.json b/plugins/quetz_content_trust/tests/data/root.json index 82cabec3..59851604 100644 --- a/plugins/quetz_content_trust/tests/data/root.json +++ b/plugins/quetz_content_trust/tests/data/root.json @@ -26,4 +26,4 @@ "type": "root", "version": 1 } -} \ No newline at end of file +} diff --git a/plugins/quetz_repodata_patching/README.md b/plugins/quetz_repodata_patching/README.md index 5e9b0773..f4817319 100644 --- a/plugins/quetz_repodata_patching/README.md +++ b/plugins/quetz_repodata_patching/README.md @@ -1,7 +1,6 @@ # quetz_repodata_patching plugin -A plugin for [quetz](https://github.com/mamba-org/quetz) package server that implements the repodata patching. Repodata patching allow for hotfixing package index by changing some metadata in ``repodata.json`` files on the fly. For more information, see [conda-build](https://docs.conda.io/projects/conda-build/en/latest/concepts/generating-index.html#repodata-patching) docs. - +A plugin for [quetz](https://github.com/mamba-org/quetz) package server that implements the repodata patching. Repodata patching allow for hotfixing package index by changing some metadata in `repodata.json` files on the fly. For more information, see [conda-build](https://docs.conda.io/projects/conda-build/en/latest/concepts/generating-index.html#repodata-patching) docs. ## Installing diff --git a/plugins/quetz_runexports/README.md b/plugins/quetz_runexports/README.md index ba644c5f..31c126fe 100644 --- a/plugins/quetz_runexports/README.md +++ b/plugins/quetz_runexports/README.md @@ -1,6 +1,6 @@ # quetz_runexports -Quetz plugin to extract and expose `run_exports` from package files. +Quetz plugin to extract and expose `run_exports` from package files. ## Installation @@ -12,7 +12,6 @@ pip install -e . The plugin should be automatically integrated with quetz server, when you start it. - ## Usage To retrieve the `run_exports` make a GET requests on the following endpoint: diff --git a/plugins/quetz_sql_authenticator/README.md b/plugins/quetz_sql_authenticator/README.md index 8312dd32..897144e7 100644 --- a/plugins/quetz_sql_authenticator/README.md +++ b/plugins/quetz_sql_authenticator/README.md @@ -24,4 +24,4 @@ The authenticator provides REST routes to create, update, and delete credentials `PUT /api/sqlauth/credentials/{username}?password={password}`: Update a user's password. -`DELETE /api/sqlauth/credentials/{username}`: Delete a user. \ No newline at end of file +`DELETE /api/sqlauth/credentials/{username}`: Delete a user. diff --git a/plugins/quetz_transmutation/README.md b/plugins/quetz_transmutation/README.md index fb923ab4..cdf5f44e 100644 --- a/plugins/quetz_transmutation/README.md +++ b/plugins/quetz_transmutation/README.md @@ -2,7 +2,6 @@ This is a plugin to use with the [quetz](https://github.com/mamba-org/quetz) package server. - ## Installing To install use: diff --git a/quetz/basic_frontend/index.html b/quetz/basic_frontend/index.html index a51d0791..33e9914e 100644 --- a/quetz/basic_frontend/index.html +++ b/quetz/basic_frontend/index.html @@ -1,10 +1,10 @@ - - + + Quetz - - -

Quetz

-login with github -login with gitlab -login with google -login with AzureAD -revoke github -revoke gitlab -revoke google -revoke AzureAD + + +

Quetz

+ login with github + login with gitlab + login with google + login with AzureAD + revoke github + revoke gitlab + revoke google + revoke AzureAD - -logout -
+ + logout +
- - + function getProfile() { + fetch("/api/me") + .then((response) => { + if (response.status === 200) { + return response.json(); + } else if (response.status === 401) { + status.innerHTML = "not logged in"; + throw Error(""); + } else { + status.innerHTML = `error: ${response.status}`; + throw Error(`error: ${response.status}`); + } + }) + .then((data) => { + var name = data.name || data.user.username; + status.innerHTML = `

Welcome ${name}


${JSON.stringify(
+              data,
+              null,
+              2
+            )}

`; + }); + } + +