Skip to content

fix: more test bugs #198

fix: more test bugs

fix: more test bugs #198

Workflow file for this run

name: tests
on:
push:
branches:
- main
pull_request: null
concurrency:
group: tests
cancel-in-progress: false
jobs:
tests:
name: test code
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: install deps
shell: bash -leo pipefail {0}
run: |
conda install --yes \
click \
ruamel.yaml \
conda \
conda-lock \
pytest \
pygithub
- name: run tests
shell: bash -leo pipefail {0}
run: |
pytest -vvs test_relock.py
tests-lock:
name: test updates
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-lock
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: check the summary
if: steps.relock.outputs.relocked == 'true'
run: |
echo ${{ steps.relock.outputs.summary }}
if [[ "${{ steps.relock.outputs.summary }}" == "" ]]; then
exit 1
fi
- name: test that PR is OK
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
gh pr checkout ${{ steps.relock.outputs.pull-request-number }}
ls -lah
if [ -f conda-lock.yml ]; then
: # do nothing
else
echo "conda-lock.yml not found"
exit 1
fi
grep numpy conda-lock.yml
grep python conda-lock.yml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-file:
name: test updates w/ file
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: make the lock file
shell: bash -leo pipefail {0}
run: |
conda install --yes conda-lock
cp test-env.yml old-test-env.yml
echo " - python =3.8" >> old-test-env.yml
conda-lock lock --file old-test-env.yml
- name: make a copy of lock file
shell: bash -leo pipefail {0}
run: |
cp conda-lock.yml old-conda-lock.yml
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
action: file
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: test that lock file is different
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
val=$(diff conda-lock.yml old-conda-lock.yml || :)
if [[ "${val}" == "" ]]; then
echo "lock files are the same"
exit 1
fi
tests-no-lock:
name: test no update
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.11
channels: conda-forge
channel-priority: strict
show-channel-urls: true
miniforge-version: latest
- name: make the lock file
shell: bash -leo pipefail {0}
run: |
conda install --yes conda-lock
conda-lock lock --file test-env.yml --lockfile conda-lockk.yml
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lockk.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-no-lock
draft: true
- name: did it not relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-skip-existing-part-1:
name: test skip existing part 1
outputs:
pull-request-number: ${{ steps.relock.outputs.pull-request-number }}
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-skip-existing
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked != 'true'
run: exit 1
- name: test that PR is OK
if: steps.relock.outputs.relocked == 'true'
shell: bash
run: |
gh pr checkout ${{ steps.relock.outputs.pull-request-number }}
ls -lah
if [ -f conda-lock.yml ]; then
: # do nothing
else
echo "conda-lock.yml not found"
exit 1
fi
grep numpy conda-lock.yml
grep python conda-lock.yml
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-skip-existing-part-2:
name: test skip existing part 2
needs: tests-skip-existing-part-1
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: conda-lock.yml
ignored-packages: ''
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-skip-existing
skip-if-pr-exists: true
draft: true
- name: did it relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ needs.tests-skip-existing-part-1.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tests-ignore:
name: test ignore
runs-on: "ubuntu-latest"
if: github.event.pull_request.title != 'relock w/ conda-lock'
steps:
- uses: actions/checkout@v4
- name: relock
id: relock
uses: ./
with:
environment-file: test-env.yml
lock-file: outdated-conda-lock.yml
relock-all-packages: false
github-token: ${{ secrets.GITHUB_TOKEN }}
automerge: false
base-branch: ${{ github.head_ref }}
head-branch: tests-ignore
ignored-packages: |
python
numpy
draft: true
- name: did it not relock?
if: steps.relock.outputs.relocked == 'true'
run: exit 1
- name: close PR
if: always()
continue-on-error: true
shell: bash
run: gh pr close ${{ steps.relock.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}