Skip to content

Commit

Permalink
+github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
subzeroid committed Mar 2, 2024
1 parent 752c7e0 commit 544d616
Show file tree
Hide file tree
Showing 19 changed files with 466 additions and 10 deletions.
35 changes: 35 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: Bug report
about: Create a report to help us improve
title: "[BUG]"
labels: bug
assignees: ''

---

### Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Provide a piece of code to reproduce the problem.

**Traceback**
Show your full traceback so that it is clear where exactly the error occurred.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. Ubuntu 21.04]
- Python version [e.g. 3.8.3]
- aiograpi version [e.g. 1.9.3, not "latest"]
- moveipy version if used
- imagemagick version if used

**Additional context**
Add any other context about the problem here.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

### Try HikerAPI SaaS with a free trial https://hikerapi.com/p/KhMxYMSn

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
14 changes: 14 additions & 0 deletions .github/actions/install-dependencies/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set -euo pipefail

echo "Ensuring pip is up to date"
python -m pip install --upgrade pip

if [[ "${INSTALL_REQUIREMENTS}" == "true" ]]; then
echo "Installing code requirements"
pip install -r requirements.txt
fi

if [[ "${INSTALL_TEST_REQUIREMENTS}" == "true" ]]; then
echo "Installing test requirements"
pip install -r requirements-test.txt
fi
20 changes: 20 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: "Install Dependencies"
description: "Install Python dependencies"
inputs:
requirements:
description: "Should requirements.txt be installed"
default: "false"
required: false
test-requirements:
description: "Should requirements-test.txt be installed"
default: "false"
required: false
runs:
using: "composite"
steps:
- name: "Install Python dependencies"
run: "$GITHUB_ACTION_PATH/action.sh"
shell: "bash"
env:
INSTALL_REQUIREMENTS: ${{ inputs.requirements }}
INSTALL_TEST_REQUIREMENTS: ${{ inputs.test-requirements }}
30 changes: 30 additions & 0 deletions .github/actions/publish-docs-with-mike/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

set -eo pipefail

echo "::group::Configure Git User"
"${GITHUB_ACTION_PATH}/configure_git_user.sh"
echo "::endgroup::"

echo "::group::Pull down latest docs commit"
git fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin gh-pages
echo "::endgroup::"

echo "::group::Publish documentation"
if [[ "${NEW_VERSION}" == "false" ]]; then
if [[ "${VERSION_NAME}" == "" ]]; then
echo "::error::'version_name' must be specified when 'NEW_VERSION' is false."
exit 1
fi
echo "mike deploy \"${VERSION_NAME}\""
mike deploy "${VERSION_NAME}"
elif [[ "${GITHUB_EVENT_NAME:-}" != "release" ]]; then
echo "::error::new_version can only be used for release events."
exit 1
else
# drop leading "v" from tag name to have just the version number
"${GITHUB_ACTION_PATH}/update_docs_for_version.sh" "${RELEASE_TAG:1}"
fi
echo "git push origin gh-pages"
git push origin gh-pages
echo "::endgroup::"
37 changes: 37 additions & 0 deletions .github/actions/publish-docs-with-mike/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Publish Docs with Mike"
description: |
Publish versioned documentation with Mike.
Requires a python environment to already be setup with mike and any other documentation dependencies installed.
inputs:
version_name:
description: |
Name a version to publish.
Required when new_version is false.
required: false
default: ""
new_version:
description: |
If true, publish a new docs version. If an existing version uses the alias/tile "latest",
update the records so that the new version becomes the latest version.
If version_name is given, that value will be used. Otherwise the release tag will be used.
required: false
default: "false"
commit_user_name:
description: "User name to use for commits. When omitted, the event values will be inspected to derive the name."
default: ""
required: false
commit_user_email:
description: "User email to use for commits. When omitted, the event values will be inspected to derive the email."
default: ""
required: false
runs:
using: "composite"
steps:
- run: "$GITHUB_ACTION_PATH/action.sh"
shell: "bash"
env:
USER_NAME: ${{ inputs.name }}
USER_EMAIL: ${{ inputs.email }}
VERSION_NAME: ${{ inputs.version_name }}
NEW_VERSION: ${{ inputs.new_version }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
45 changes: 45 additions & 0 deletions .github/actions/publish-docs-with-mike/configure_git_user.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

set -euo pipefail

NO_REPLY_SUFFIX="@users.noreply.github.com"

function set_and_exit() {
local name="${USER_NAME:-$1}"
local email="${USER_EMAIL:-$2}"
git config --local user.name "${name}"
git config --local user.email "${email}"
exit 0
}

function json_query() {
jq -e "${1}" "${GITHUB_EVENT_PATH}"
}

if [[ "${USER_NAME}" != "" && "${USER_EMAIL}" != "" ]]; then
set_and_exit
fi

echo "::debug::Attempting push event pusher"
if json_query ".push.pusher" > /dev/null ; then
echo "::debug::Found push event pusher"
set_and_exit "$(json_query '.push.pusher.name')" "$(json_query '.push.pusher.email')"
fi

echo "::debug::Attempting merge merged by"
if json_query ".pull_request.merged_by" > /dev/null ; then
echo "::debug::Found pull request event merged by"
LOGIN="$(json_query '.pull_request.merged_by.login')"
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}"
fi

echo "::debug::Attempting event sender"
if json_query ".sender" > /dev/null ; then
echo "::debug::Found pull event sender"
LOGIN="$(json_query '.sender.login')"
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}"
fi

echo "::debug::Falling back to GITHUB_ACTOR"
LOGIN="${GITHUB_ACTOR:-github_action}"
set_and_exit "${LOGIN}" "${LOGIN}${NO_REPLY_SUFFIX}"
15 changes: 15 additions & 0 deletions .github/actions/publish-docs-with-mike/update_docs_for_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -eo pipefail

NEW_VERSION="${1}"
PREV_LATEST="$(mike list --json | jq --raw-output '.[] | select(.aliases == ["latest"]) | .version')"

if [[ "${PREV_LATEST}" == "" ]]; then
echo "No previous version found using the latest alias. Nothing to retitle."
else
echo "mike retitle --message \"Remove latest from title of ${PREV_LATEST}\" \"${PREV_LATEST}\" \"${PREV_LATEST}\""
mike retitle --message "Remove latest from title of ${PREV_LATEST}" "${PREV_LATEST}" "${PREV_LATEST}"
fi
echo "mike deploy --update-aliases --title \"${NEW_VERSION} (latest)\" \"${NEW_VERSION}\" \"latest\""
mike deploy --update-aliases --title "${NEW_VERSION} (latest)" "${NEW_VERSION}" "latest"
19 changes: 19 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/docker"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# 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:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '28 6 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

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

# 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.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# 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.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Loading

0 comments on commit 544d616

Please sign in to comment.