From e8f3599cd5fa2139ef807168752e73f703e128fc Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 21 Sep 2023 16:56:46 -0500 Subject: [PATCH] ci: improve workflow --- .github/workflows/build.yml | 54 ++++++++++++++++++++++++++++--------- conda_requirements.txt | 6 ----- environment.yml | 7 +++++ 3 files changed, 48 insertions(+), 19 deletions(-) delete mode 100644 conda_requirements.txt create mode 100644 environment.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a29e10..9a9f596 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,36 +1,64 @@ name: Install and Test -on: [push, pull_request] +on: + pull_request: + branches: + - main + push: + branches: + - main jobs: build-linux: + defaults: + run: + # Ensures environment gets sourced right + shell: bash -l {0} name: Python (${{ matrix.PYTHON_VERSION }}) runs-on: ubuntu-latest strategy: matrix: - PYTHON_VERSION: ["3.8", "3.9", "3.10"] + PYTHON_VERSION: ["3.9", "3.10", "3.11"] env: PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Add /etc/hosts entries run: | echo 127.0.0.1 rtstats.local | sudo tee -a /etc/hosts echo 127.0.0.1 memcached.local | sudo tee -a /etc/hosts echo 127.0.0.1 rtstatstest | sudo tee -a /etc/hosts + + # setup conda-forge with micromamba + - name: Setup Python + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: environment.yml + condarc: | + channels: + - conda-forge + - defaults + create-args: >- + python=${{ env.PYTHON_VERSION }} + environment-name: prod + cache-environment: true - - name: Setup CI from ci-tooling + - name: Copy default settings run: | + cp config/settings.json-in config/settings.json + + - name: Setup Postgres + run: | + git clone --depth 1 https://github.com/akrherz/iem-database.git database git clone --depth 1 https://github.com/akrherz/ci_tooling.git .ci_tooling . .ci_tooling/postgres.sh - sudo ln -s `pwd` /opt/rtstats - . .ci_tooling/miniconda.sh - . .ci_tooling/mod_wsgi.sh - pip install --upgrade pip - cp config/settings.json-in config/settings.json - export PATH="/usr/lib/postgresql/11/bin:$PATH" - psql -c 'CREATE ROLE runner SUPERUSER LOGIN CREATEDB;' -U postgres || true cd database; sh bootstrap.sh python schema_manager.py - cd .. + + - name: Install requirements via pip + run: | + python -m pip install -r pip_requirements.txt + + - name: Setup and run example + run: | + sudo ln -s `pwd` /opt/rtstats cat test/rtstats_example.txt | python app/run.py - sudo cat /var/log/apache2/error.log diff --git a/conda_requirements.txt b/conda_requirements.txt deleted file mode 100644 index c80d47f..0000000 --- a/conda_requirements.txt +++ /dev/null @@ -1,6 +0,0 @@ -matplotlib-base -pandas -psycopg2 -python-memcached -pytz -twisted diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..e54188f --- /dev/null +++ b/environment.yml @@ -0,0 +1,7 @@ +dependencies: + - matplotlib-base + - pandas + - psycopg2 + - python-memcached + - pytz + - twisted