Skip to content

Commit 5c47175

Browse files
authored
Merge branch 'main' into k8s_fix_import
2 parents 6ec5196 + 21a7c95 commit 5c47175

21 files changed

Lines changed: 626 additions & 287 deletions

.github/workflows/ansible-test-integration.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,40 @@ jobs:
2424
- stable-2.18
2525
- stable-2.19
2626
env:
27-
ansible-collections-path: "./ansible_collections/scaleway/scaleway"
27+
ansible-collections-path: "./ansible_collections/scaleway/scaleway"
2828

2929
steps:
30-
- name: Create directory
31-
run: |
32-
mkdir -p ${{ env.ansible-collections-path }}
33-
34-
- name: Checkout the repo
35-
uses: actions/checkout@v4
36-
with:
37-
path: ${{ env.ansible-collections-path }}
38-
39-
- name: Setup Python and install ansible
40-
uses: actions/setup-python@v5
41-
with:
42-
python-version: 3.11
43-
44-
- name: Install ansible
45-
run: |
46-
python -m pip install \
47-
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz \
48-
--disable-pip-version-check
49-
50-
- name: Create scw config
51-
run: |
52-
mkdir -p $HOME/.config/scw
53-
cat << EOF > $HOME/.config/scw/config.yaml
54-
access_key: ${{ secrets.SCW_ACCESS_KEY }}
55-
secret_key: ${{ secrets.SCW_SECRET_KEY }}
56-
default_region: ${{ secrets.SCW_DEFAULT_REGION }}
57-
default_project_id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
58-
EOF
59-
60-
- name: Run integration tests with ansible ${{ matrix.ansible-version }}
61-
working-directory: ${{ env.ansible-collections-path }}
62-
run: |
63-
ansible-test integration -v --requirements ${{ matrix.module }}
30+
- name: Create directory
31+
run: |
32+
mkdir -p ${{ env.ansible-collections-path }}
33+
34+
- name: Checkout the repo
35+
uses: actions/checkout@v4
36+
with:
37+
path: ${{ env.ansible-collections-path }}
38+
39+
- name: Setup Python and install ansible
40+
uses: actions/setup-python@v5
41+
with:
42+
python-version: 3.11
43+
44+
- name: Install ansible
45+
run: |
46+
python -m pip install \
47+
https://github.com/ansible/ansible/archive/${{ matrix.ansible-version }}.tar.gz \
48+
--disable-pip-version-check
49+
50+
- name: Create scw config
51+
run: |
52+
mkdir -p $HOME/.config/scw
53+
cat << EOF > $HOME/.config/scw/config.yaml
54+
access_key: ${{ secrets.SCW_ACCESS_KEY }}
55+
secret_key: ${{ secrets.SCW_SECRET_KEY }}
56+
default_region: ${{ secrets.SCW_DEFAULT_REGION }}
57+
default_project_id: ${{ secrets.SCW_DEFAULT_PROJECT_ID }}
58+
EOF
59+
60+
- name: Run integration tests with ansible ${{ matrix.ansible-version }}
61+
working-directory: ${{ env.ansible-collections-path }}
62+
run: |
63+
ansible-test integration -v --requirements ${{ matrix.module }}

.github/workflows/ansible-test-units.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- stable-2.17
2323
- stable-2.18
2424
env:
25-
ansible-collections-path: "./ansible_collections/scaleway/scaleway"
25+
ansible-collections-path: "./ansible_collections/scaleway/scaleway"
2626

2727
runs-on: ubuntu-latest
2828
steps:
@@ -49,4 +49,4 @@ jobs:
4949
- name: Run unit tests with ansible ${{ matrix.ansible-version }}
5050
working-directory: ${{ env.ansible-collections-path }}
5151
run: |
52-
ansible-test units -v --requirements
52+
ansible-test units -v --requirements

.github/workflows/format.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Format
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
9+
jobs:
10+
ruff:
11+
name: Format
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: astral-sh/ruff-action@v2
16+
with:
17+
args: "format --check"

.github/workflows/integration-nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ on:
77
jobs:
88
integration:
99
uses: ./.github/workflows/ansible-test-integration.yml
10-
secrets: inherit
10+
secrets: inherit

.github/workflows/lint.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Check linters
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
merge_group:
12+
13+
jobs:
14+
ruff:
15+
name: Ruff
16+
runs-on: ubuntu-24.04
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: astral-sh/ruff-action@v2

.github/workflows/typing.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Check type hinting
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
merge_group:
12+
13+
jobs:
14+
ty:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Install poetry
19+
run: pipx install poetry
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.13"
24+
cache: "poetry"
25+
- name: Install dependencies and library
26+
run: poetry install
27+
- name: Check typing
28+
run: poetry run ty check
29+
30+
pyrefly:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v4
34+
- name: Install poetry
35+
run: pipx install poetry
36+
- name: Set up Python
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: "3.13"
40+
cache: "poetry"
41+
- name: Install dependencies and library
42+
run: poetry install
43+
- name: Check typing with pyrefly
44+
run: poetry run pyrefly check

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ dmypy.json
133133

134134
# Archive files
135135
*.tar.gz
136+
137+
tests/.../inventory

CONTRIBUTING.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Contributing to Scaleway Ansible Collection
2+
3+
Thank you for contributing to the Scaleway Ansible Collection! This guide will help you set up your development environment and run tests properly.
4+
5+
## Repository Structure
6+
7+
The repository must be placed in the correct path for Ansible to recognize it:
8+
```
9+
ansible_collections/scaleway/scaleway/
10+
```
11+
12+
## Environment Setup
13+
14+
### Virtual Environment
15+
Always use a virtual environment when working on this project:
16+
```bash
17+
python -m venv .venv
18+
source .venv/bin/activate # On macOS/Linux
19+
```
20+
21+
### Dependencies
22+
Install the required dependencies:
23+
```bash
24+
pip install -r requirements.txt
25+
```
26+
27+
## Testing
28+
29+
### Integration Tests
30+
Run integration tests with:
31+
```bash
32+
ansible-test integration scaleway_secret --requirements
33+
```
34+
35+
**Note**: `ansible-test` does not read environment variables. For local testing with specific profiles, use `ansible-playbook` directly:
36+
```bash
37+
SCW_PROFILE=owner SCW_DEFAULT_REGION=fr-par SCW_CONFIG_PATH="/path/to/config.yml" ansible-playbook playbook.yaml
38+
```
39+
40+
### Unit Tests
41+
Run unit tests with:
42+
```bash
43+
ansible-test units --python-interpreter .venv/bin/python
44+
```
45+
46+
**MacOS Users**: You may need to set this environment variable:
47+
```bash
48+
export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
49+
```
50+
51+
**Important**: `ansible-test sanity` ignores the Python path argument, which is why you'll see import checks like:
52+
```python
53+
try:
54+
import scaleway
55+
except ImportError:
56+
# handle import error
57+
```
58+
59+
To test quickly your changes without writing a test you can export the collection path `export ANSIBLE_COLLECTIONS_PATH=/Users/gnoale/git/scaleway/ansible_collections`
60+
61+
## Development Guidelines
62+
63+
### Python Compatibility
64+
- Be mindful of Python versions and dependencies
65+
- The target system receives module code and is subject to your declared dependencies
66+
67+
### Type Hints
68+
When using types from the Scaleway SDK in function signatures, wrap them in quotes to avoid import issues during validation:
69+
```python
70+
def example_function(client: "Client") -> str:
71+
pass
72+
```
73+
74+
75+
## Running Playbooks
76+
77+
Example playbook execution:
78+
```yaml
79+
---
80+
- hosts: localhost
81+
tasks:
82+
- name: Create a secret
83+
scaleway.scaleway.scaleway_secret:
84+
name: "test-secret"
85+
protected: false
86+
state: present
87+
vars:
88+
ansible_python_interpreter: .venv/bin/python
89+
```
90+
91+
Execute with:
92+
```bash
93+
SCW_PROFILE=owner SCW_DEFAULT_REGION=fr-par SCW_CONFIG_PATH="/path/to/config.yml" ansible-playbook playbook.yaml
94+
```

0 commit comments

Comments
 (0)