Skip to content

Commit

Permalink
update ci, fix act tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloDePieri committed Jul 13, 2024
1 parent 98b63f0 commit 0a91c4f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .actrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#-P ubuntu-latest=carlodepieri/ubuntu:act-py-latest
-P ubuntu-latest=catthehacker/ubuntu:act-latest
30 changes: 10 additions & 20 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,22 @@ jobs:
steps:

- name: Checkout.
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: '3.8.x'

- uses: actions/setup-python@v2
with:
python-version: '3.9.x'

- uses: actions/setup-python@v2
with:
python-version: '3.10.x'

- uses: actions/setup-python@v2
with:
python-version: '3.11.x'

- uses: actions/setup-python@v2
with:
python-version: '3.12.x'
python-version: |
3.8.x
3.9.x
3.10.x
3.11.x
3.12.x
- name: Make sure path are there also for act shells.
if: env.using_act == 'true'
run: |
echo "export PATH=\"/opt/hostedtoolcache/Python/${{ env.python_version }}/x64:/opt/hostedtoolcache/Python/${{ env.python_version }}/x64/bin:$PATH\"" >> /root/.bashrc
- name: Upgrade pip.
run: python -m pip install --upgrade pip

Expand All @@ -66,4 +56,4 @@ jobs:
run: poetry config virtualenvs.in-project true

- name: Install dependencies and test for all supported python version
run: inv test-all-python-version
run: inv test-all-python-versions
30 changes: 10 additions & 20 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,22 @@ jobs:
steps:

- name: Checkout.
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: '3.8.x'

- uses: actions/setup-python@v2
with:
python-version: '3.9.x'

- uses: actions/setup-python@v2
with:
python-version: '3.10.x'

- uses: actions/setup-python@v2
with:
python-version: '3.11.x'

- uses: actions/setup-python@v2
with:
python-version: '3.12.x'
python-version: |
3.8.x
3.9.x
3.10.x
3.11.x
3.12.x
- name: Make sure path are there also for act shells.
if: env.using_act == 'true'
run: |
echo "export PATH=\"/opt/hostedtoolcache/Python/${{ env.python_version }}/x64:/opt/hostedtoolcache/Python/${{ env.python_version }}/x64/bin:$PATH\"" >> /root/.bashrc
- name: Upgrade pip.
run: python -m pip install --upgrade pip

Expand All @@ -66,7 +56,7 @@ jobs:
run: poetry config virtualenvs.in-project true

- name: Install dependencies and test for all supported python version
run: inv test-all-python-version --coverage
run: inv test-all-python-versions --coverage

- name: Prepare the coveralls config.
run: |
Expand Down
17 changes: 11 additions & 6 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_spec(c, m=None):


@task()
def test_all_python_version(c, coverage=False):
def test_all_python_versions(c, coverage=False):
cov = ""
if coverage:
cov = " --cov=vcrpy_encrypt"
Expand All @@ -81,6 +81,8 @@ def test_all_python_version(c, coverage=False):
python_version = supported_python_versions.copy()
python_version.reverse()
for version in python_version:
print("\n>>> Make sure cassettes folder is empty\n")
clear_cassettes(c)
print(f"\n>>> Installing python venv with version: {version}\n")
reinstall(c, python=version)
print(f"\n>>> Running tests with version: {version}\n")
Expand All @@ -107,7 +109,8 @@ def test_cov(c, m=None):
if m is not None:
marks = f" -m {m}"
c.run(
f"poetry run pytest --cov=vcrpy_encrypt --cov-report annotate:coverage/cov_annotate --cov-report html:coverage/cov_html{marks}", pty=True)
f"poetry run pytest --cov=vcrpy_encrypt --cov-report annotate:coverage/cov_annotate --cov-report "
f"html:coverage/cov_html{marks}", pty=True)


@task(test_cov)
Expand All @@ -125,19 +128,21 @@ def html_cov(c):

@task
def act_prod(c, cmd=""):
act_ctx = c.run(f"docker ps | grep {act_prod_ctx} | cut -d' ' -f1", hide=True).stdout.strip()
if cmd == "":
c.run("act -W .github/workflows/prod.yml", pty=True)
elif cmd == "shell":
c.run(f"docker exec --env-file {act_secrets_file} -it {act_prod_ctx} bash", pty=True)
c.run(f"docker exec --env-file {act_secrets_file} -it {act_ctx} bash", pty=True)
elif cmd == "clean":
c.run(f"docker rm -f {act_prod_ctx}", pty=True)
c.run(f"docker rm -f {act_ctx}", pty=True)


@task
def act_dev(c, cmd=""):
act_ctx = c.run(f"docker ps | grep {act_dev_ctx} | cut -d' ' -f1", hide=True).stdout.strip()
if cmd == "":
c.run("act -W .github/workflows/dev.yml", pty=True)
elif cmd == "shell":
c.run(f"docker exec --env-file {act_secrets_file} -it {act_dev_ctx} bash", pty=True)
c.run(f"docker exec --env-file {act_secrets_file} -it {act_ctx} bash", pty=True)
elif cmd == "clean":
c.run(f"docker rm -f {act_dev_ctx}", pty=True)
c.run(f"docker rm -f {act_ctx}", pty=True)

0 comments on commit 0a91c4f

Please sign in to comment.