diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..a4ff987 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,67 @@ +name: CI + +on: + pull_request: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + lint-format: + name: Check linting and formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + with: + fetch-depth: 0 + + - name: pip update + run: python -m pip install --upgrade pip + + - name: Install dependencies + run: python -m pip install build setuptools_scm[toml] + + - name: Install dependencies + run: python -m pip install .[dev] + + - name: Lint + run: python -m ruff . + + - name: Check format + run: python -m ruff format . + + - name: Check Diff + run: | + DIFF="$(git diff --name-only)" + + if [ -z "$DIFF" ]; then + echo "OK: Format is clean" + else + echo "Error: Format was not clean" + echo "List of files:" + echo "$DIFF" + git diff + exit 1 + fi + + build-test: + name: Build and test Python + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3 + with: + fetch-depth: 0 + + - name: pip update + run: python -m pip install --upgrade pip + + - name: Install dependencies + run: python -m pip install build setuptools_scm[toml] + + - name: Install dependencies + run: python -m pip install .[tests] + + - name: Run tests + run: python -m pytest tests + diff --git a/src/armonik_cli/admin.py b/src/armonik_cli/admin.py index 7d307c4..154818c 100644 --- a/src/armonik_cli/admin.py +++ b/src/armonik_cli/admin.py @@ -145,7 +145,7 @@ def list_results(client: ArmoniKResults, result_filter: Filter): results = client.list_results(result_filter, page=page) while len(results[1]) > 0: for result in results[1]: - print(f'Result ID: {result.result_id}') + print(f'Result ID: {result}') page += 1 results = client.list_results(result_filter, page=page) @@ -175,6 +175,9 @@ def get_task_durations(client: ArmoniKTasks, task_filter: Filter): for partition, duration in durations.items(): print(f"Partition: {partition} = {duration} secondes") +def hello(): + return "Hello, World!" + def main(): diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/test_hello.py b/tests/unit/test_hello.py new file mode 100644 index 0000000..ddae264 --- /dev/null +++ b/tests/unit/test_hello.py @@ -0,0 +1,4 @@ +from armonik_cli.admin import hello + +def test_hello(): + assert hello() == "Hello, World!"