Skip to content

Commit

Permalink
Merge branch 'main' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
danieltsoukup committed Jan 14, 2024
2 parents 3c91d8e + d133a64 commit 5ec0251
Show file tree
Hide file tree
Showing 6 changed files with 218 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Deployment workflow to Heroku in a Docker container

name: "Build-and-Deploy"

on: [ workflow_call ]

jobs:
build-and-deploy:
name: docker-build-deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Add API key from secret
run: |
echo "API_TOKEN=${{ secrets.TOKEN }}"
- name: Docker build
run: |
make prod_build
- name: Deploy to Heroku
uses: ./.github/workflows/heroku-deploy.yml

81 changes: 81 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
workflow_call:
schedule:
- cron: '20 3 * * 6'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
# required for all workflows
security-events: write

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
18 changes: 18 additions & 0 deletions .github/workflows/dev-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Development Checks - Test and Security Analysis

name: "Dev Workflow"

on:
push:
branches: [ "development" ]
pull_request:
branches: [ "development" ]

jobs:
analyze:
name: codeql
uses: ./.github/workflows/codeql.yml

tests:
name: tests
uses: ./.github/workflows/test.yml
32 changes: 32 additions & 0 deletions .github/workflows/heroku-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Heroku login and deploy workflow
# Requires
# - GitHub secrets with Heroku credentials
# - Access to the makefile

name: Heroku-Login-Deploy

on: [ workflow_call ]

jobs:
login-deploy:
name: login-and-deploy
runs-on: ubuntu-latest
steps:
- name: login
run: |
cat <<EOF > ~/.netrc
machine api.heroku.com
login ${{ secrets.HEROKU_EMAIL }}
password ${ secrets.HEROKU_API_KEY }
machine git.heroku.com
login ${{ secrets.HEROKU_EMAIL }}
password ${{ secrets.HEROKU_API_KEY }}
EOF

- name: heroku-push
run: |
make heroku_push
- name: heroku-release
run: |
make heroku_release
23 changes: 23 additions & 0 deletions .github/workflows/main-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# This CI/CD workflow will test, build a container and deploy the app to Heroku.

name: "CI/CD Workflow"

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

jobs:
codeql:
name: codeql
uses: ./.github/workflows/codeql.yml

tests:
name: tests
uses: ./.github/workflows/test.yml

deploy:
name: build and deploy
needs: [ tests, codeql ]
uses: ./.github/workflows/build-deploy.yml
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: "Test-and-Lint"

on: [ workflow_call ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
shell: bash
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
pytest

0 comments on commit 5ec0251

Please sign in to comment.