Some checks failed
Test Collection / Sanity Tests (Ansible devel) (push) Failing after 13s
Test Collection / Sanity Tests (Ansible stable-2.15) (push) Failing after 1m20s
Test Collection / Sanity Tests (Ansible stable-2.16) (push) Failing after 1m11s
Test Collection / Sanity Tests (Ansible stable-2.17) (push) Failing after 1m14s
Test Collection / Python Syntax Check (push) Successful in 7s
Test Collection / Build Collection (push) Failing after 21s
Test Collection / YAML and Ansible Lint (push) Successful in 12s
Test Collection / Documentation Check (push) Successful in 7s
Test Collection / Unit Tests (push) Successful in 7s
125 lines
3.0 KiB
Markdown
125 lines
3.0 KiB
Markdown
# Gitea Actions CI/CD
|
|
|
|
This collection includes automated testing and publishing workflows using Gitea Actions.
|
|
|
|
## Workflows
|
|
|
|
### Test Workflow (`.gitea/workflows/test.yml`)
|
|
|
|
Automatically runs on push and pull requests to main/master/develop branches.
|
|
|
|
**Jobs:**
|
|
|
|
1. **Sanity Tests** - Runs ansible-test sanity checks across multiple Ansible versions (2.15, 2.16, 2.17, devel)
|
|
2. **Python Syntax Check** - Validates Python syntax for all module files
|
|
3. **Build Collection** - Builds the collection tarball and verifies contents
|
|
4. **YAML/Ansible Lint** - Runs yamllint and ansible-lint (non-blocking)
|
|
5. **Documentation Check** - Validates module documentation can be parsed
|
|
6. **Unit Tests** - Runs unit tests when available (non-blocking)
|
|
|
|
**Trigger manually:**
|
|
```bash
|
|
git push origin main
|
|
# Or create a pull request
|
|
```
|
|
|
|
### Publish Workflow (`.gitea/workflows/publish.yml`)
|
|
|
|
Publishes the collection to Ansible Galaxy.
|
|
|
|
**Triggers:**
|
|
- Automatically on GitHub/Gitea release
|
|
- Manually via workflow dispatch
|
|
|
|
**Setup:**
|
|
|
|
1. Generate an API token from [Ansible Galaxy](https://galaxy.ansible.com/me/preferences)
|
|
2. Add the token as a secret in your repository:
|
|
- Go to repository Settings → Secrets
|
|
- Add new secret: `GALAXY_API_TOKEN`
|
|
- Paste your Galaxy API token
|
|
|
|
**Manual trigger:**
|
|
- Go to Actions tab
|
|
- Select "Publish to Galaxy" workflow
|
|
- Click "Run workflow"
|
|
- Enter version number (e.g., 1.0.0)
|
|
|
|
## Running Tests Locally
|
|
|
|
### Python Syntax Check
|
|
```bash
|
|
python -m py_compile plugins/modules/nsupdate_zone.py
|
|
python -m py_compile plugins/module_utils/deps.py
|
|
```
|
|
|
|
### Build Collection
|
|
```bash
|
|
ansible-galaxy collection build
|
|
```
|
|
|
|
### Sanity Tests
|
|
```bash
|
|
# Setup collection path structure
|
|
mkdir -p ansible_collections/valid
|
|
ln -s $(pwd) ansible_collections/valid/nsupdate_zone
|
|
cd ansible_collections/valid/nsupdate_zone
|
|
|
|
# Run sanity tests
|
|
ansible-test sanity --docker
|
|
```
|
|
|
|
### YAML Lint
|
|
```bash
|
|
pip install yamllint
|
|
yamllint .
|
|
```
|
|
|
|
### Ansible Lint
|
|
```bash
|
|
pip install ansible-lint
|
|
ansible-lint
|
|
```
|
|
|
|
## Workflow Status
|
|
|
|
Add a badge to your README:
|
|
|
|
```markdown
|
|

|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Sanity Tests Fail
|
|
|
|
- Ensure all Python files have correct syntax
|
|
- Check that DOCUMENTATION, EXAMPLES, and RETURNS are valid YAML
|
|
- Verify module follows Ansible module development guidelines
|
|
|
|
### Build Fails
|
|
|
|
- Check `galaxy.yml` is valid
|
|
- Ensure all required files are present
|
|
- Verify file permissions are correct
|
|
|
|
### Publish Fails
|
|
|
|
- Verify `GALAXY_API_TOKEN` secret is set correctly
|
|
- Check that version in `galaxy.yml` is incremented
|
|
- Ensure no version conflicts on Galaxy
|
|
|
|
## Required Secrets
|
|
|
|
For the publish workflow to work, configure this secret in your repository:
|
|
|
|
- `GALAXY_API_TOKEN` - Your Ansible Galaxy API token
|
|
|
|
## Supported Ansible Versions
|
|
|
|
The CI tests against:
|
|
- Ansible 2.15 (stable)
|
|
- Ansible 2.16 (stable)
|
|
- Ansible 2.17 (stable)
|
|
- Ansible devel (latest development version)
|