Merge pull request #6 from sousa-miguel/dev-ci-pipeline #9
This file contains 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: CI Pipeline | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
permissions: | |
contents: write | |
id-token: write | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: github.event_name == 'pull_request' | |
with: | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
if: github.event_name == 'push' | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' # caching pip dependencies | |
- name: Install dependencies | |
run: pip install -r ./requirements.txt | |
- name: Lint | |
run: python3 -m black ./ | |
- name: Commit any differences after linting | |
if: github.event_name == 'pull_request' | |
run: | | |
if [ "$(git status | grep -i 'modified\|untracked' | wc -l)" -gt "0" ]; then | |
echo "Detected some changes after linting, committing them now..." | |
git add . | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git commit -m "Linting changes" | |
git push | |
fi | |
- name: Test | |
run: python3 -m pytest ./ | |