Skip to content

Commit

Permalink
Add lesson 5 workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
timothywarner committed Jan 9, 2024
1 parent 3ba540e commit 37b1f36
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/environment-protections.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Multi-Environment Deployment

on:
push:
branches:
- alpha

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: python -m unittest

deploy-dev:
needs: build
runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v2
- name: Deploy to Development
run: echo "Deploying to Development environment..."

deploy-test:
needs: build
runs-on: ubuntu-latest
environment: test
steps:
- uses: actions/checkout@v2
- name: Deploy to Test
run: echo "Deploying to Test environment..."

deploy-prod:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment: prod
steps:
- uses: actions/checkout@v2
- name: Deploy to Production
run: echo "Deploying to Production environment..."
33 changes: 33 additions & 0 deletions .github/workflows/install-cache-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Install and cache dependencies

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Cache Python dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-python-${{ hashFiles('**/src/requirements.txt') }}
restore-keys: |
${{ runner.os }}-python-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r src/requirements.txt
# Add additional steps for linting, testing, etc.
37 changes: 37 additions & 0 deletions .github/workflows/job-config-matrix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python Matrix Testing

on:
push:
branches: [ alpha ]
pull_request:
branches: [ alpha ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, 3.10]
framework: ['flask', 'django']
include:
- framework: 'flask'
additional-package: 'Flask-Testing'
- framework: 'django'
additional-package: 'Django-Testing'
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install ${{ matrix.additional-package }}
- name: Run tests
run: |
if [ ${{ matrix.framework }} = 'flask' ]; then
# run Flask tests
elif [ ${{ matrix.framework }} = 'django' ]; then
# run Django tests
fi
31 changes: 31 additions & 0 deletions .github/workflows/workflow-approval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deployment with Approval Gates

on:
push:
branches:
- alpha

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: python -m unittest

deploy-to-prod:
needs: build-and-test
runs-on: ubuntu-latest
environment:
name: production
steps:
- uses: actions/checkout@v2
- name: Deploy to Production
run: echo "Deploying to production environment..."
# Replace with actual deployment commands
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/
__pycache__

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 37b1f36

Please sign in to comment.