Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/jinja2-3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-robert authored Jun 12, 2023
2 parents c61c605 + 5bf9cd7 commit eef304d
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 27 deletions.
45 changes: 38 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ name: CI
on:
push:
branches: [master]
tags:
- v*
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
python-version: 3.9

- name: Install dependencies
run: |
Expand All @@ -29,7 +28,7 @@ jobs:
run: poetry run pre-commit run --all-files

test:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
Expand Down Expand Up @@ -58,3 +57,35 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
codecov --token="$CODECOV_TOKEN"
publish:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/v')
needs:
- lint
- test
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade poetry
poetry --version
- name: Check tag is correct
run: |
[ $(poetry version -s) = ${GITHUB_REF##refs/tags/v} ]
- name: Build artifacts
run: poetry build

- name: Publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: poetry publish
6 changes: 3 additions & 3 deletions docs/challenge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ challenge does not exist.
Deployment
----------

In rCDS, you define first define all of the :ref:`containers
<challenge#containers>` that your challenge needs to run, and then declare how
you want them :ref:`exposed <challenge#expose>` to the world.
In rCDS, you first define all of the :ref:`containers <challenge#containers>`
that your challenge needs to run, and then declare how you want them
:ref:`exposed <challenge#expose>` to the world.

``deployed`` --- whether or not this challenge's containers should be deployed.
Defaults to ``true``.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "rcds"
version = "0.1.3"
version = "0.1.4"
description = "An automated CTF challenge deployment tool"
readme = "README.rst"
authors = ["redpwn <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion rcds/backends/k8s/manifests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
KIND_TO_API_VERISON = {
"Deployment": "apps/v1",
"Service": "v1",
"Ingress": "networking.k8s.io/v1beta1",
"Ingress": "networking.k8s.io/v1",
"NetworkPolicy": "networking.k8s.io/v1",
}

Expand Down
10 changes: 3 additions & 7 deletions tests/challenge/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,11 @@ def test_nonexistent_flag_file(configloader, test_datadir) -> None:


def test_warn_multiline_flag(configloader, test_datadir) -> None:
with pytest.warns(RuntimeWarning) as record:
with pytest.warns(
RuntimeWarning, match=r"^Flag contains multiple lines; is this intended\?$"
):
cfg, errors = configloader.check_config(test_datadir / "challenge.yml")
assert errors is None
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert (
str(record[0].message.args[0])
== "Flag contains multiple lines; is this intended?"
)


def test_default_category(configloader, test_datadir) -> None:
Expand Down
10 changes: 2 additions & 8 deletions tests/project/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,17 @@ def test_extra_file(self, datadir: Path, am_fn: assets.AssetManager) -> None:
file1 = ctx._root / "files" / "file1"
with file1.open("w") as fd:
fd.write("abcd")
with pytest.warns(RuntimeWarning) as record:
with pytest.warns(RuntimeWarning, match=r"^Unexpected item found in cache: "):
ctx.sync(check=True)
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert "Unexpected item found in cache: " in str(record[0].message.args[0])
assert not file1.exists()

def test_extra_dir(self, datadir: Path, am_fn: assets.AssetManager) -> None:
asset_manager = am_fn
ctx = asset_manager.create_context("challenge")
dir1 = ctx._root / "files" / "dir1"
dir1.mkdir()
with pytest.warns(RuntimeWarning) as record:
with pytest.warns(RuntimeWarning, match=r"^Unexpected item found in cache: "):
ctx.sync(check=True)
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert "Unexpected item found in cache: " in str(record[0].message.args[0])
assert not dir1.exists()

def test_broken_link(self, datadir: Path, am_fn: assets.AssetManager) -> None:
Expand Down

0 comments on commit eef304d

Please sign in to comment.