From 8cd555b96c1bbbb884323c66f9b0c7fabc7340eb Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 11 Dec 2021 14:28:55 -0800 Subject: [PATCH] Separate out PR tests and scheduled tests --- .github/actions/run_tests.yml | 48 +++++++++++++ .github/workflows/testing.yaml | 90 ------------------------- .github/workflows/testing_prs.yaml | 37 ++++++++++ .github/workflows/testing_schedule.yaml | 22 ++++++ 4 files changed, 107 insertions(+), 90 deletions(-) create mode 100644 .github/actions/run_tests.yml delete mode 100644 .github/workflows/testing.yaml create mode 100644 .github/workflows/testing_prs.yaml create mode 100644 .github/workflows/testing_schedule.yaml diff --git a/.github/actions/run_tests.yml b/.github/actions/run_tests.yml new file mode 100644 index 00000000..679ba81b --- /dev/null +++ b/.github/actions/run_tests.yml @@ -0,0 +1,48 @@ +steps: +- run: git config --global core.autocrlf false +- uses: actions/checkout@v2 + +- name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + +- name: Capture full Python version in env + run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV + +- name: poetry cache # Change CACHE_STRING secret to bust the cache + uses: actions/cache@v2 + with: + path: .venv + key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ secrets.CACHE_STRING }} + +- name: Install dependencies + run: | + echo '::group::poetry' + pip --disable-pip-version-check install poetry + poetry config --local virtualenvs.in-project true + echo '::endgroup::' + + echo '::group::Other dependencies' + poetry install --remove-untracked + echo '::endgroup::' + + echo 'DEPS_INSTALLED=true' >> $GITHUB_ENV + +- name: Code formatting (Black) + if: ${{ env.DEPS_INSTALLED == 'true' }} + run: | + poetry run black --version + poetry run black --check --diff . + +- name: Code Style (flake8) + if: > + ${{ env.DEPS_INSTALLED == 'true' }} + run: | + poetry run pflake8 --version + poetry run pflake8 jrnl tests + +- name: Test with pytest + if: > + ${{ env.DEPS_INSTALLED == 'true' }} + run: poetry run pytest --junitxml=reports/pytest/results.xml diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml deleted file mode 100644 index 80bdd5d9..00000000 --- a/.github/workflows/testing.yaml +++ /dev/null @@ -1,90 +0,0 @@ -name: Testing - -on: - push: - branches: [ develop, release ] - paths: - - 'jrnl/**' - - 'features/**' - - 'tests/**' - - 'poetry.lock' - - 'pyproject.toml' - - '.github/workflows/testing.yaml' - pull_request: - branches: [ develop ] - paths: - - 'jrnl/**' - - 'features/**' - - 'tests/**' - - 'poetry.lock' - - 'pyproject.toml' - - '.github/workflows/testing.yaml' - schedule: - - cron: '0 0 * * SAT' - -defaults: - run: - shell: bash # needed to prevent Windows from using PowerShell - -jobs: - test: - if: > - ! contains(github.event.head_commit.message, '[ci skip]') - runs-on: ${{ matrix.os }} - continue-on-error: ${{ matrix.python-version == '3.11-dev' }} - strategy: - fail-fast: false - matrix: - python-version: [ 3.7, 3.8, 3.9, '3.10', 3.11-dev ] - os: [ ubuntu-latest, macos-latest, windows-latest ] - - steps: - - run: git config --global core.autocrlf false - - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Capture full Python version in env - run: echo "PYTHON_FULL_VERSION=$(python --version)" >> $GITHUB_ENV - - - name: poetry cache # Change CACHE_STRING secret to bust the cache - uses: actions/cache@v2 - with: - path: .venv - key: ${{ runner.os }}-${{ hashFiles('poetry.lock') }}-${{ env.PYTHON_FULL_VERSION }}-${{ secrets.CACHE_STRING }} - - - name: Install dependencies - run: | - echo '::group::poetry' - pip --disable-pip-version-check install poetry - poetry config --local virtualenvs.in-project true - echo '::endgroup::' - - echo '::group::Other dependencies' - poetry install --remove-untracked - echo '::endgroup::' - - echo 'DEPS_INSTALLED=true' >> $GITHUB_ENV - - - name: Code formatting (Black) - if: ${{ env.DEPS_INSTALLED == 'true' }} - run: | - poetry run black --version - poetry run black --check --diff . - - - name: Code Style (flake8) - if: > - ${{ (matrix.python-version != '3.11-dev' || github.event_name == 'schedule') - && env.DEPS_INSTALLED == 'true' }} - run: | - poetry run pflake8 --version - poetry run pflake8 jrnl tests - - - name: Test with pytest - if: > - ${{ (matrix.python-version != '3.11-dev' || github.event_name == 'schedule') - && env.DEPS_INSTALLED == 'true' }} - run: poetry run pytest --junitxml=reports/pytest/results.xml diff --git a/.github/workflows/testing_prs.yaml b/.github/workflows/testing_prs.yaml new file mode 100644 index 00000000..dedde0bc --- /dev/null +++ b/.github/workflows/testing_prs.yaml @@ -0,0 +1,37 @@ +name: Testing + +on: + push: + branches: [ develop, release ] + paths: + - 'jrnl/**' + - 'features/**' + - 'tests/**' + - 'poetry.lock' + - 'pyproject.toml' + - '.github/workflows/testing.yaml' + pull_request: + branches: [ develop ] + paths: + - 'jrnl/**' + - 'features/**' + - 'tests/**' + - 'poetry.lock' + - 'pyproject.toml' + - '.github/workflows/testing.yaml' + +defaults: + run: + shell: bash # needed to prevent Windows from using PowerShell + +jobs: + test: + if: > + ! contains(github.event.head_commit.message, '[ci skip]') + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: [ 3.7, 3.8, 3.9, '3.10' ] + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: ./.github/actions/run_tests.yml diff --git a/.github/workflows/testing_schedule.yaml b/.github/workflows/testing_schedule.yaml new file mode 100644 index 00000000..c5acb87e --- /dev/null +++ b/.github/workflows/testing_schedule.yaml @@ -0,0 +1,22 @@ +name: Testing + +on: + schedule: + - cron: '0 0 * * SAT' + +defaults: + run: + shell: bash # needed to prevent Windows from using PowerShell + +jobs: + test_all: + if: > + ! contains(github.event.head_commit.message, '[ci skip]') + github.event_name == 'schedule' + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + python-version: [ 3.7, 3.8, 3.9, '3.10', 3.11-dev ] + os: [ ubuntu-latest, macos-latest, windows-latest ] + steps: ./.github/actions/run_tests.yml