Github Actions

My first project

  • New Python project
  • Feature cards written out
  • Set up locally
  • Started writing code + tests
  • Needed to get reviews
  • Validate everything works as expected
    • "Set up TeamCity"

Pros of TeamCity

  • Runs tests automatically
  • Can run deployments
  • Receive feedback
  • Have multiple ways to run a build (automated vs manual)

Day One experience

  • Did not have permissions
  • Got permissions to view
  • Could not set up project

What is Github Actions

  • CI/CD offered by Github
    • Similar offerings from Gitlab, Bitbucket
  • Manifest(s) stay in codebase
    • Self contained

Why Github Actions?

  • Easy to start creating
    • As soon as your Github project is created
  • Works as setup documentation
    • Writing file to work for tests = local setup
  • Consists of Docker containers
    • Public or private
  • Not limited by environments (came up during RSAPI testing)
  • 10k minutes of build per month

Writing a manifest

  • YML based
  • Goes in .github/actions/FILENAME.yml

First part

Writing the name of the action + when its triggered

name: "Name of action when displayed in UI"
# Below is when action is triggered
on:
  push:
    branches:
      - master
    tags:
      - v[0-9]+.[0-9]+.[0-9]+
  pull_request: {}
  schedule:
      - cron: "0 * * * *"

Writing the job(s)

A job consists of one or more steps

jobs:
  build:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-python@v1
  with:
    python-version: '3.6'
    architecture: 'x64'
  - name: Set up flask environment variables
    run: |
      echo "FLASK_ENV=development" > .env
  - name: Install dependencies
    run: |
      pip install pipenv
      pipenv sync --dev --bare
  - name: Run unit tests via coverage
    run: |
      find tests -name "*.py" | xargs pipenv run coverage run -m pytest
...

Demo

Resources

  • https://github.com/features/actions
  • https://github.com/actions/starter-workflows
  • https://github.com/marketplace?type=actions

Github Actions

By btmash

Github Actions

  • 768