aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yaml64
-rw-r--r--.github/workflows/lint.yaml (renamed from .github/workflows/lint-build-deploy.yaml)83
-rw-r--r--bot/exts/evergreen/branding.py4
-rw-r--r--bot/exts/halloween/candy_collection.py6
-rw-r--r--bot/exts/halloween/hacktoberstats.py6
5 files changed, 85 insertions, 78 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
new file mode 100644
index 00000000..404e66f7
--- /dev/null
+++ b/.github/workflows/build.yaml
@@ -0,0 +1,64 @@
+name: Build
+
+on:
+ workflow_run:
+ workflows: ["Lint"]
+ branches:
+ - master
+ types:
+ - completed
+
+jobs:
+ build:
+ if: github.event.workflow_run.conclusion == 'success'
+ name: Build, Push, & Deploy Container
+ runs-on: ubuntu-latest
+
+ steps:
+ # Create a commit SHA-based tag for the container repositories
+ - name: Create SHA Container Tag
+ id: sha_tag
+ run: |
+ tag=$(cut -c 1-7 <<< $GITHUB_SHA)
+ echo "::set-output name=tag::$tag"
+
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Login to Github Container Registry
+ uses: docker/login-action@v1
+ with:
+ registry: ghcr.io
+ username: ${{ github.repository_owner }}
+ password: ${{ secrets.GHCR_TOKEN }}
+
+ # Build and push the container to the GitHub Container
+ # Repository. The container will be tagged as "latest"
+ # and with the short SHA of the commit.
+ - name: Build and push
+ uses: docker/build-push-action@v2
+ with:
+ context: .
+ file: ./Dockerfile
+ push: true
+ cache-from: type=registry,ref=ghcr.io/python-discord/seasonalbot:latest
+ tags: |
+ ghcr.io/python-discord/seasonalbot:latest
+ ghcr.io/python-discord/seasonalbot:${{ steps.sha_tag.outputs.tag }}
+
+ - name: Authenticate with Kubernetes
+ uses: azure/k8s-set-context@v1
+ with:
+ method: kubeconfig
+ kubeconfig: ${{ secrets.KUBECONFIG }}
+
+ - name: Deploy to Kubernetes
+ uses: Azure/k8s-deploy@v1
+ with:
+ manifests: |
+ deployment.yaml
+ images: 'ghcr.io/python-discord/seasonalbot:${{ steps.sha_tag.outputs.tag }}'
+ kubectl-version: 'latest'
diff --git a/.github/workflows/lint-build-deploy.yaml b/.github/workflows/lint.yaml
index c70e49b7..063f406c 100644
--- a/.github/workflows/lint-build-deploy.yaml
+++ b/.github/workflows/lint.yaml
@@ -1,15 +1,15 @@
-name: Lint, Build & Deploy
+name: Lint
on:
push:
branches:
- master
- pull_request_target:
+ pull_request:
jobs:
lint:
- name: Lint using pre-commit & flake8
+ name: Run pre-commit & flake8
runs-on: ubuntu-latest
env:
# Configure pip to cache dependencies and do a user install
@@ -32,12 +32,8 @@ jobs:
- name: Add custom PYTHONUSERBASE to PATH
run: echo '${{ env.PYTHONUSERBASE }}/bin/' >> $GITHUB_PATH
- # We don't want to persist credentials, as our GitHub Action
- # may be run when a PR is made from a fork.
- name: Checkout repository
uses: actions/checkout@v2
- with:
- persist-credentials: false
- name: Setup python
id: python
@@ -84,67 +80,14 @@ jobs:
- name: Run pre-commit hooks
run: export PIP_USER=0; SKIP=flake8 pre-commit run --all-files
- # This step requires `pull_request_target` as we need "write" permissions
- # to add annotations to the Actions results. A normal `pull_request` trigger
- # does not get those permissions for security reasons.
+ # Run flake8 and have it format the linting errors in the format of
+ # the GitHub Workflow command to register error annotations. This
+ # means that our flake8 output is automatically added as an error
+ # annotation to both the run result and in the "Files" tab of a
+ # pull request.
+ #
+ # Format used:
+ # ::error file={filename},line={line},col={col}::{message}
- name: Run flake8
- uses: julianwachholz/flake8-action@v1
- with:
- checkName: lint
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
- build-and-deploy:
- name: Build and Deploy to Kubernetes
- needs: lint
- if: github.event_name != 'pull_request_target' && github.ref == 'refs/heads/master'
- runs-on: ubuntu-latest
-
- steps:
- # Create a commit SHA-based tag for the container repositories
- - name: Create SHA Container Tag
- id: sha_tag
- run: |
- tag=$(cut -c 1-7 <<< $GITHUB_SHA)
- echo "::set-output name=tag::$tag"
-
- - name: Checkout code
- uses: actions/checkout@v2
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v1
-
- - name: Login to Github Container Registry
- uses: docker/login-action@v1
- with:
- registry: ghcr.io
- username: ${{ github.repository_owner }}
- password: ${{ secrets.GHCR_TOKEN }}
-
- # Build and push the container to the GitHub Container
- # Repository. The container will be tagged as "latest"
- # and with the short SHA of the commit.
- - name: Build and push
- uses: docker/build-push-action@v2
- with:
- context: .
- file: ./Dockerfile
- push: true
- cache-from: type=registry,ref=ghcr.io/python-discord/seasonalbot:latest
- tags: |
- ghcr.io/python-discord/seasonalbot:latest
- ghcr.io/python-discord/seasonalbot:${{ steps.sha_tag.outputs.tag }}
-
- - name: Authenticate with Kubernetes
- uses: azure/k8s-set-context@v1
- with:
- method: kubeconfig
- kubeconfig: ${{ secrets.KUBECONFIG }}
-
- - name: Deploy to Kubernetes
- uses: Azure/k8s-deploy@v1
- with:
- manifests: |
- deployment.yaml
- images: 'ghcr.io/python-discord/seasonalbot:${{ steps.sha_tag.outputs.tag }}'
- kubectl-version: 'latest'
+ run: "flake8 \
+ --format='::error file=%(path)s,line=%(row)d,col=%(col)d::[flake8] %(code)s: %(text)s'"
diff --git a/bot/exts/evergreen/branding.py b/bot/exts/evergreen/branding.py
index b55c9b14..fa607270 100644
--- a/bot/exts/evergreen/branding.py
+++ b/bot/exts/evergreen/branding.py
@@ -1,6 +1,6 @@
import asyncio
import itertools
-import json
+# import json
import logging
import random
import typing as t
@@ -18,7 +18,7 @@ from bot.seasons import SeasonBase, get_all_seasons, get_current_season, get_sea
from bot.utils import human_months
from bot.utils.decorators import with_role
from bot.utils.exceptions import BrandingError
-# TODO: Implement substitute for current volume persistence requirements
+# TODO: Implement substitute for current volume persistence requirements # noqa: T000
# from bot.utils.persist import make_persistent
log = logging.getLogger(__name__)
diff --git a/bot/exts/halloween/candy_collection.py b/bot/exts/halloween/candy_collection.py
index 7bdc6ef0..bd0b90cc 100644
--- a/bot/exts/halloween/candy_collection.py
+++ b/bot/exts/halloween/candy_collection.py
@@ -1,7 +1,7 @@
import json
import logging
import random
-from pathlib import Path
+# from pathlib import Path
from typing import Union
import discord
@@ -10,7 +10,7 @@ from discord.ext import commands
from bot.constants import Channels, Month
from bot.utils.decorators import in_month
-# TODO: Implement substitutes for volume-persistent methods.
+# TODO: Implement substitutes for volume-persistent methods. # noqa: T000
# from bot.utils.persist import make_persistent
log = logging.getLogger(__name__)
@@ -39,7 +39,7 @@ class CandyCollection(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
- self.json_file = make_persistent(Path("bot", "resources", "halloween", "candy_collection.json"))
+ # self.json_file = make_persistent(Path("bot", "resources", "halloween", "candy_collection.json"))
with self.json_file.open() as fp:
candy_data = json.load(fp)
diff --git a/bot/exts/halloween/hacktoberstats.py b/bot/exts/halloween/hacktoberstats.py
index beff86e3..4fd5c324 100644
--- a/bot/exts/halloween/hacktoberstats.py
+++ b/bot/exts/halloween/hacktoberstats.py
@@ -3,7 +3,7 @@ import logging
import re
from collections import Counter
from datetime import datetime, timedelta
-from pathlib import Path
+# from pathlib import Path
from typing import List, Tuple, Union
import aiohttp
@@ -13,7 +13,7 @@ from discord.ext import commands
from bot.constants import Channels, Month, Tokens, WHITELISTED_CHANNELS
from bot.utils.decorators import in_month, override_in_channel
-# TODO: Implement substitutes for volume-persistent methods.
+# TODO: Implement substitutes for volume-persistent methods. # noqa: T000
# from bot.utils.persist import make_persistent
log = logging.getLogger(__name__)
@@ -41,7 +41,7 @@ class HacktoberStats(commands.Cog):
def __init__(self, bot: commands.Bot):
self.bot = bot
- self.link_json = make_persistent(Path("bot", "resources", "halloween", "github_links.json"))
+ # self.link_json = make_persistent(Path("bot", "resources", "halloween", "github_links.json"))
self.linked_accounts = self.load_linked_users()
@in_month(Month.SEPTEMBER, Month.OCTOBER, Month.NOVEMBER)