From e2accab87e3b5d339cb5695eb55908ff52b235c3 Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Wed, 19 Apr 2023 01:27:29 +0200 Subject: [PATCH] Move to Python 3.10 & improve CI workflow (#2369) * Use Python 3.10 in CI, benchmark, devcontainer, docker config, .sourcery.yaml * Improve Python CI workflow --- .devcontainer/Dockerfile | 8 +++--- .github/workflows/benchmark.yml | 4 +-- .github/workflows/ci.yml | 46 +++++++++++++++++++++++---------- .sourcery.yaml | 4 +-- Dockerfile | 2 +- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 379f631068c7..02f580a02e11 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,10 +1,10 @@ -# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster +# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3-bullseye, 3.10-bullseye, 3-buster, 3.10-buster ARG VARIANT=3-bullseye -FROM --platform=linux/amd64 python:3.8 +FROM --platform=linux/amd64 python:3.10 RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131 - && apt-get purge -y imagemagick imagemagick-6-common + && apt-get purge -y imagemagick imagemagick-6-common # Temporary: Upgrade python packages due to https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-40897 # They are installed by the base image (python) which does not have the patch. @@ -25,4 +25,4 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ # && apt-get -y install --no-install-recommends # [Optional] Uncomment this line to install global node packages. -# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 \ No newline at end of file +# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index c5a42b2c0c35..750366d8ba9f 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -9,11 +9,11 @@ jobs: environment: benchmark strategy: matrix: - python-version: [3.8] + python-version: ['3.10'] steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2eb34b9d61a0..f437a71c0113 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,26 +2,24 @@ name: Python CI on: push: - branches: - - master + branches: [master] pull_request: - branches: - - '**' - pull_request_target: - branches: - - '**' + branches: [master] + +concurrency: + group: ${{ format('ci-{0}', format('pr-{0}', github.event.pull_request.number) || github.sha) }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - build: + lint: runs-on: ubuntu-latest - strategy: matrix: - python-version: [3.8] + python-version: ['3.10'] steps: - name: Check out repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -34,16 +32,35 @@ jobs: pip install -r requirements.txt - name: Lint with flake8 - continue-on-error: false run: flake8 - name: Check black formatting - continue-on-error: false run: black . --check + if: success() || failure() - name: Check isort formatting - continue-on-error: false run: isort . --check + if: success() || failure() + + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.10'] + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt - name: Run unittest tests with coverage run: | @@ -53,3 +70,4 @@ jobs: run: | coverage report coverage xml + if: success() || failure() diff --git a/.sourcery.yaml b/.sourcery.yaml index a7f5b9d7616d..da171e7598f4 100644 --- a/.sourcery.yaml +++ b/.sourcery.yaml @@ -30,7 +30,7 @@ rule_settings: - refactoring - suggestion - comment - python_version: '3.9' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. + python_version: '3.10' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version. # rules: # A list of custom rules Sourcery will include in its analysis. # - id: no-print-statements @@ -68,4 +68,4 @@ rule_settings: # proxy: # url: # ssl_certs_file: -# no_ssl_verify: false \ No newline at end of file +# no_ssl_verify: false diff --git a/Dockerfile b/Dockerfile index 09b5303db944..8396154998f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Use an official Python base image from the Docker Hub -FROM python:3.11-slim +FROM python:3.10-slim # Install git RUN apt-get -y update