From 12dd1dc19bbd82621e7e64d220754ff15f12526a Mon Sep 17 00:00:00 2001 From: Mike Graves Date: Fri, 11 Oct 2019 14:42:27 -0400 Subject: [PATCH] Add Github Actions This is an initial attempt at setting up Github Actions. It's not optimal, but it does the job until I can figure out better ways to do things. The biggest issue is that I think the tests workflow should probably be turned into an action since it's reused in both the test and deploy workflows. On push the usual CI jobs will run. On merging into master the CI jobs will run and then, if successful, a new image for the workflow container will be built and deployed. The staging Airflow cluster will be redeployed with the new image. --- .github/workflows/deploy.yml | 51 ++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 22 ++++++++++++++++ tox.ini | 2 +- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f8af254 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: Deploy +on: + push: + branches: + - master +env: + AWS_DEFAULT_REGION: us-east-1 +jobs: + test: + name: Run tests + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + runs-on: ubuntu-latest + strategy: + matrix: + tox: [flake8, safety, py37, coveralls] + steps: + - uses: actions/checkout@master + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: x64 + - name: Install tox + run: pip install tox + - name: Run tox env + run: tox -e ${{ matrix.tox }} + deploy: + name: Deploy new workflow image + runs-on: ubuntu-latest + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + needs: test + steps: + - uses: actions/checkout@master + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: x64 + - name: Install dependencies + run: | + python3.7 -m pip install pipenv awscli + make install + - name: Build container + run: make dist + - name: Publish container + run: make publish + - name: Redeploy cluster + run: pipenv run workflow redeploy --yes diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..17bb566 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Tests +on: push +jobs: + test: + name: Run tests + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + runs-on: ubuntu-latest + strategy: + matrix: + tox: [flake8, safety, py37, coveralls] + steps: + - uses: actions/checkout@master + - name: Setup python + uses: actions/setup-python@v1 + with: + python-version: '3.7' + architecture: x64 + - name: Install tox + run: pip install tox + - name: Run tox env + run: tox -e ${{ matrix.tox }} diff --git a/tox.ini b/tox.ini index b2aac2b..5e5986a 100644 --- a/tox.ini +++ b/tox.ini @@ -23,7 +23,7 @@ commands = pipenv run flake8 manager tests commands = pipenv check [testenv:coveralls] -passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH +passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH COVERALLS_REPO_TOKEN commands = pipenv install --dev