Skip to content

thread safety refactor #40

thread safety refactor

thread safety refactor #40

Workflow file for this run

name: Ansible-Link CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
ansible-link-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set up python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Update configuration
working-directory: ${{ github.workspace }}/src
run: |
sed -i '/^playbook_dir:/d' config.yml
sed -i '/^inventory_file:/d' config.yml
sed -i '/^job_storage_dir:/d' config.yml
sed -i '/^log_level:/d' config.yml
sed -i '/^playbook_whitelist:/d' config.yml
echo "playbook_dir: './test_playbooks'" >> config.yml
echo "inventory_file: './test_inventory.ini'" >> config.yml
echo "job_storage_dir: './test_job_storage'" >> config.yml
echo "log_level: 'DEBUG'" >> config.yml
echo "playbook_whitelist:" >> config.yml
echo " - test_.+\.yml$" >> config.yml
- name: Create test files/folders
working-directory: ${{ github.workspace }}/src
run: |
mkdir -p test_playbooks test_job_storage
touch test_inventory.ini
- name: Create test playbook
working-directory: ${{ github.workspace }}/src
run: |
cat << EOF > test_playbooks/test_playbook.yml
---
- name: Test Playbook
hosts: localhost
connection: local
tasks:
- name: Print a message
debug:
msg: "This is a test playbook"
EOF
- name: Show structure and files
working-directory: ${{ github.workspace }}/src
run: |
pwd
echo "LS --------------------"
ls -R
echo "CONFIG --------------------"
cat config.yml
echo "PLAYBOOK --------------------"
cat test_playbooks/test_playbook.yml
- name: Run tests
run: |
python -m unittest discover src
create-tag-and-release:
needs: ansible-link-ci
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Get version
id: get_version
run: |
echo "VERSION=$(python -c "from src.version import VERSION; print(VERSION)")" >> $GITHUB_OUTPUT
- name: Create tag
run: |
git config user.name github-actions
git config user.email [email protected]
git tag -a v${{ steps.get_version.outputs.VERSION }} -m "Release version ${{ steps.get_version.outputs.VERSION }}"
git push origin v${{ steps.get_version.outputs.VERSION }}
- name: Create zip artifact
run: |
(cd src && zip -r ../ansible-link-${{ steps.get_version.outputs.VERSION }}.zip . -x "*.pyc" "*__pycache__*" "*test_*")
zip -j ansible-link-${{ steps.get_version.outputs.VERSION }}.zip requirements.txt
- name: Create hash file
run: |
find src -type f -exec sha256sum {} + > ansible-link-${{ steps.get_version.outputs.VERSION }}.sha256
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.VERSION }}
name: Release ${{ steps.get_version.outputs.VERSION }}
body_path: ${{ github.workspace }}/CHANGELOG.md
files: |
ansible-link-${{ steps.get_version.outputs.VERSION }}.zip
ansible-link-${{ steps.get_version.outputs.VERSION }}.sha256
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}