Skip to content

Commit

Permalink
add github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Gaultney committed Feb 19, 2021
1 parent 3af81cf commit 82805df
Show file tree
Hide file tree
Showing 10 changed files with 244 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tests:
- tests/**/*

core:
- xoto3/**/*

dependencies:
- Pipfile*

internal:
- ./CHANGES.md

documentation:
- ./README.md
31 changes: 31 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
change-template: "* $TITLE (#$NUMBER) by @$AUTHOR"
categories:
- title: "⚡ Breaking Changes"
labels:
- "breaking-change"
- title: "🌟New features and non-breaking changes"
labels:
- "major"
- "feature"
- title: "🌟 Minor Changes"
labels:
- "enhancement"
- title: "📜 Documentation updates"
labels:
- "documentation"
- title: "🐛 Bug and hot fixes"
labels:
- "bug"
- "fix"
- title: "🚒 Deprecations"
labels:
- "deprecated"
exclude-labels:
- "skip-changelog"
tag-template: "v$NEXT_PATCH_VERSION"
template: |
## Changes
**[Human readable summary of changes]**
$CHANGES
## This release was made possible by the following contributors:
$CONTRIBUTORS
15 changes: 15 additions & 0 deletions .github/semantic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
types:
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
- improv

titleOnly: true
29 changes: 29 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: "CodeQL"

on:
push:
branches: [develop]
pull_request:
branches: [develop]

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: ["python"]

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

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
11 changes: 11 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "PR Labeler"
on:
- pull_request_target

jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@main
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
58 changes: 58 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Publish

# RELEASE PROCESS
#
# === Manual ===
#
# 1. Document human readable changes in CHANGES
# 2. Bump package version
# 3. Create a PR to develop branch
# 4. Edit the current draft release notes
# 5. If not already set, use `v<new version>` as a tag, and select develop as target branch
#
# === Automated ===
#
# 1. Extract release notes name that was published
# 2. Ensure release notes name match what's in CHANGES
# 5. Publish package to PyPi
# 6. Push latest release source code to master using release title as the commit message

on:
release:
types: [published]

jobs:
upload:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v2
with:
python-version: "3.7"
- name: Set release notes name
run: |
export RELEASE_NAME_VERSION=${{ github.event.release.name }}
echo "RELEASE_NAME_VERSION=${RELEASE_NAME_VERSION}" >> $GITHUB_ENV
- name: Ensure new version is also set in CHANGES.md
run: |
grep --regexp "${RELEASE_NAME_VERSION}" CHANGES.md
- name: Setup & Build
run: |
python -m pip install --upgrade pip
python -m pip install pipenv
export PATH=/home/runner/.local/bin:$PATH
pipenv install --dev --skip-lock
python setup.py sdist
- name: pypi-publish
uses: pypa/[email protected]
with:
user: xoi-technologies
password: ${{ secrets.PYPI_API_TOKEN }}
sync_main:
needs: upload
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Sync main from detached head
run: git push origin HEAD:refs/heads/main --force
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- develop

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Contributing

Please be nice.

### Issues

Please open bugs using GitHub. Please provide a `pytest` style unit
test that reproduces the issue if at all possible.

### PRs

Please feel free to fork and make PRs from your fork.

### Code style

We use `pytest` for running tests and aim for 100% code coverage since
this is a pure library.

All code must have appropriate static type annotations that work with
`mypy`.

Please `pre-commit install` before making any commits. Our style
guidelines will be enforced by those [hooks](https://pre-commit.com/).

### Suggestions and comments

We're interested to hear what you think and what you'd do
differently. You can open a GitHub issue for general feedback as well.
11 changes: 11 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Security Policy

## Reporting a Vulnerability

Please email `[email protected]` with any concerns about security.

## Supported Versions

We do not provide any guarantees, security or otherwise, for this project, as per the license agreement.

If security issues arise, we will update this document with information about which versions have been patched.
33 changes: 33 additions & 0 deletions dev-utils/watch-cloudwatch-log-stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from datetime import datetime, timedelta
from functools import partial

import boto3

from xoto3.paginate import yield_pages_from_operation

cw_client = boto3.client("logs")

start_time = (datetime.utcnow() - timedelta(hours=20)).timestamp() * 1000
end_time = datetime.utcnow().timestamp() * 1000

query = dict(
logGroupName="xoi-ecs-logs-devl",
logStreamNamePrefix="dataplateocr/dataplateocrContainer",
startTime=int(start_time),
endTime=int(end_time),
)

nt = ("nextToken",)
CLOUDWATCH_FILTER_LOG_EVENTS = (
nt,
nt,
("limit",),
("events",),
)

yield_cloudwatch_pages = partial(yield_pages_from_operation, *CLOUDWATCH_FILTER_LOG_EVENTS,)


for page in yield_cloudwatch_pages(cw_client.filter_log_events, query,):
for event in page["events"]:
print(event["message"])

0 comments on commit 82805df

Please sign in to comment.