Update r1.cfg #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Batfish CI | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'snapshots/ci_net/**/*' | |
| jobs: | |
| batfish-ci: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Start Batfish (Docker) | |
| run: | | |
| sudo docker run -d --name batfish -p 8888:8888 -p 9996:9996 batfish/allinone | |
| # wait until Batfish API responds | |
| for i in {1..60}; do | |
| if curl -sSf http://localhost:9996/v2/version >/dev/null 2>&1; then | |
| echo "Batfish ready"; break | |
| fi | |
| sleep 1 | |
| done | |
| - name: Setup Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install Python deps | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install pybatfish==2025.7.7.2423 ansible pytest jinja2 | |
| - name: Prepare Batfish snapshot | |
| run: | | |
| sudo mkdir -p snapshots/ci_net/s1/configs/manual | |
| sudo mkdir -p snapshots/ci_net/s1/configs/generated | |
| sudo mkdir -p backup | |
| - name: Generate configs from yaml if have | |
| run: python tools/conf-generator.py | |
| - name: Copy configs to snapshot (Ansible) | |
| run: ansible-playbook ansible/playbook.yml -i ansible/hosts | |
| - name: Run Pytest script | |
| run: python tests/test_batfish.py | |
| - name: Backup generated configs | |
| if: success() | |
| run: | | |
| cp snapshots/ci_net/s1/configs/generated/*.cfg backup/ | |
| cp snapshots/ci_net/s1/configs/manual/*.cfg backup/ | |
| echo "Configs backed up successfully." | |
| - name: Commit and push backups | |
| if: success() | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add backup/ | |
| git diff --staged --quiet || git commit -m "Backup configs after successful validation" | |
| git config --unset-all http.https://github.com/.extraheader || true | |
| git remote set-url origin https://x-access-token:${GH_PAT}@github.com/${{ github.repository }} | |
| git push origin HEAD:main |