Skip to content

CI pipeline

CI pipeline #40

Workflow file for this run

name: CI pipeline
on:
pull_request:
branches:
- main
permissions:
contents: write
issues: write
pull-requests: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.0'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Run Ruff Linter
run: |
ruff check --exclude=ecommerce/settings --exclude=store/migrations --fix
ruff format --exclude=store/migrations store ecommerce
- name: Check for changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Apply Ruff fixes"
git push origin HEAD:${{ github.ref }}
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.0'
- name: Set up environment variables
run: |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> $GITHUB_ENV
echo "DJANGO_DEBUG=False" >> $GITHUB_ENV
echo "ALLOWED_HOSTS=localhost,127.0.0.1" >> $GITHUB_ENV
echo "WORKING_ENV=${{ secrets.WORKING_ENV }}" >> $GITHUB_ENV
echo "STRIPE_API_KEY=${{ secrets.STRIPE_API_KEY }}" >> $GITHUB_ENV
echo "STRIPE_WEBHOOK_KEY=${{ secrets.STRIPE_WEBHOOK_KEY }}" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/prod/requirements.txt
pip install -r requirements/dev-requirements.txt
- name: Collect static files
run: |
python manage.py collectstatic --noinput --settings=ecommerce.settings.dev
- name: Run unit tests
run: python manage.py test store.tests --settings=ecommerce.settings.dev --parallel
coverage:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.0'
- name: Set up environment variables
run: |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> $GITHUB_ENV
echo "DJANGO_DEBUG=False" >> $GITHUB_ENV
echo "ALLOWED_HOSTS=localhost,127.0.0.1" >> $GITHUB_ENV
echo "WORKING_ENV=${{ secrets.WORKING_ENV }}" >> $GITHUB_ENV
echo "STRIPE_API_KEY=${{ secrets.STRIPE_API_KEY }}" >> $GITHUB_ENV
echo "STRIPE_WEBHOOK_KEY=${{ secrets.STRIPE_WEBHOOK_KEY }}" >> $GITHUB_ENV
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/prod/requirements.txt
pip install -r requirements/dev-requirements.txt
- name: Collect static files
run: |
python manage.py collectstatic --noinput --settings=ecommerce.settings.dev
- name: Run unit tests
run: coverage run manage.py test store.tests --settings=ecommerce.settings.dev --parallel
- name: Report coverage
run: coverage report