From f119b60514ef170bbd83fb58634443114ab1e0c6 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 5 Apr 2022 16:30:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20CI:=20Update=20GH=20action=20wor?= =?UTF-8?q?kflows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/{tests.yml => cd.yml} | 32 +++++-- .github/workflows/ci.yml | 119 ++++++++++++++++++++++++ .pre-commit-config.yaml | 2 +- 3 files changed, 146 insertions(+), 7 deletions(-) rename .github/workflows/{tests.yml => cd.yml} (76%) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/cd.yml similarity index 76% rename from .github/workflows/tests.yml rename to .github/workflows/cd.yml index a506eff..93da81f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/cd.yml @@ -1,11 +1,9 @@ -name: CI +name: CD on: push: - branches: [master, develop] tags: - - 'v*' - pull_request: + - "v[0-9]+.[0-9]+.[0-9]+*" jobs: @@ -18,7 +16,29 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.8 - - uses: pre-commit/action@v2.0.0 + id: cache-pip + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: pip-${{ matrix.python-version }}-tests-${{ hashFiles('**/setup.json') }} + restore-keys: + pip-${{ matrix.python-version }}-tests + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Upgrade pip + run: | + pip install --upgrade pip + pip --version + - name: Install wheel + run: pip install wheel + - name: Install AiiDA-LAMMPS + run: | + pip install -e .[testing,pre-commit] + pip freeze + - name: Run pre-commit + run: pre-commit run --all-files || ( git diff; git status; exit 1; ) tests: @@ -82,7 +102,7 @@ jobs: - name: Installation run: | - pip install -e .[testing] + pip install -e .[testing,pre-commit] reentry scan - name: Run pytest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..f092092 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,119 @@ +name: CI + +on: + push: + branches: [master, develop] + pull_request: + +jobs: + + pre-commit: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + id: cache-pip + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: pip-${{ matrix.python-version }}-tests-${{ hashFiles('**/setup.json') }} + restore-keys: + pip-${{ matrix.python-version }}-tests + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Upgrade pip + run: | + pip install --upgrade pip + pip --version + - name: Install wheel + run: pip install wheel + - name: Install AiiDA-LAMMPS + run: | + pip install -e .[testing,pre-commit] + pip freeze + - name: Run pre-commit + run: pre-commit run --all-files || ( git diff; git status; exit 1; ) + + tests: + + timeout-minutes: 30 + + strategy: + fail-fast: false + matrix: + include: + - python-version: 3.7 + lammps-version: "2019.06.05" + backend: django + - python-version: 3.7 + lammps-version: "2019.06.05" + backend: sqlalchemy + - python-version: 3.8 + lammps-version: "2020.12.24" + backend: django + - python-version: 3.9 + lammps-version: "2020.12.24" + backend: django + + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10 + env: + POSTGRES_DB: test_${{ matrix.backend }} + POSTGRES_PASSWORD: '' + POSTGRES_HOST_AUTH_METHOD: trust + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + rabbitmq: + image: rabbitmq:latest + ports: + - 5672:5672 + + steps: + - uses: actions/checkout@v2 + + - name: Setup conda + uses: s-weigand/setup-conda@v1 + with: + # update-conda: true + python-version: ${{ matrix.python-version }} + conda-channels: conda-forge + + - name: install lammps + run: conda install -y lammps==${{ matrix.lammps-version }} + + - name: Upgrade pip + run: | + pip install --upgrade pip + pip --version + + - name: Installation + run: | + pip install -e .[testing,pre-commit] + reentry scan + + - name: Run pytest + run: | + pytest --lammps-exec lmp_serial --cov=aiida_lammps --cov-report=xml --cov-report=term-missing + + - name: Upload to Codecov + if: matrix.python-version == 3.8 + uses: codecov/codecov-action@v1 + with: + name: pytests-lammps + flags: pytests + file: ./coverage.xml + fail_ci_if_error: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b1649d..4191fd6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ exclude: > repos: - - repo: git://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - id: check-json