1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
# Github Action
PyFunceble can be used within a GitHub Action container.
The idea is to run PyFunceble within a GitHub Action container and let PyFunceble push the result into a Git Repository.
## Environment Variables
| Environment Variable | Description |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| GITHUB_ACTIONS | The variable PyFunceble will look for to decide which CI "engine" to use. **BEWARE:** If you use this variable to test locally, your configurations may get messy. Please test within an isolated environment. |
| PYFUNCEBLE_AUTO_CONFIGURATION | Let PyFunceble manage the configuration files. |
| PYFUNCEBLE_CONFIG_DIR | Let PyFunceble know where it should store its configuration files. |
| GITHUB_TOKEN | The token PyFunceble has to use to push changes to the repository. |
| GIT_NAME | The `git.name` to setup and use. |
| GIT_EMAIL | The `git.email` to setup and use. |
| GIT_BRANCH | The Git branch to use to store testing results between serveral sessions. |
| GIT_DISTRIBUTION_BRANCH | The Git branch to use to store and distribute the final results. |
## Example
Here is an example that demonstrate how to use PyFunceble within a GitHub Workflow.
```yaml title=".github/workflows/main.yml"
name: PyFunceble CI tests
on:
push:
branches:
- "my-awesome-branch"
pull_request:
branches:
- "my-awesome-branch"
env:
# Let PyFunceble know that it has to manage the configuration by itself.
PYFUNCEBLE_AUTO_CONFIGURATION: "YES"
# We want PyFunceble to push result to the branch, therefore, we need to
# declare our git settings.
GIT_NAME: "${{ secrets.GIT_BOT_NAME }}"
GIT_EMAIL: "${{ secrets.GIT_BOT_EMAIL }}"
# Define the branch PyFunceble has to use while working.
GIT_BRANCH: my-awesome-branch
# Define the branch PyFunceble will push the final result into.
GIT_DISTRIBUTION_BRANCH: my-awesome-branch
# Define the path of the configuration directory.
PYFUNCEBLE_CONFIG_DIR: "${{ github.workspace }}/.pyfunceble"
# By settings this variable, PyFunceble will use its GitHub Action feature
# to setup and push to the current repository.
GITHUB_TOKEN: "${{ secrets.BOT_REPO_PAT }}"
jobs:
single:
name: Run PyFunceble with a single domain
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
python_version:
- "3.12"
os:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Clone repository
with:
token: "${{ secrets.BOT_REPO_PAT }}"
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
pip install pyfunceble-dev
- name: Get PyFunceble version
run: |
pyfunceble --version
- name: Run PyFunceble
run: |
pyfunceble -a --logging-level critical -d github.com
file_and_push:
name: Run PyFunceble against a file and push result to repository
runs-on: "${{ matrix.os }}"
strategy:
fail-fast: false
matrix:
python_version:
- "3.12"
os:
- ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Clone repository
with:
token: "${{ secrets.BOT_REPO_PAT }}"
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Install dependencies
run: |
pip install pyfunceble-dev
- name: Get PyFunceble version
run: |
pyfunceble --version
- name: Run PyFunceble
# Warning: this assume that the test.list file is at the root of the
# repository.
run: |
pyfunceble -a --ci --logging-level critical -f test.list
```
|