Skip to content

Commit 54bf6ce

Browse files
committed
Add GitHub actions
1 parent e62f645 commit 54bf6ce

File tree

7 files changed

+336
-0
lines changed

7 files changed

+336
-0
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
ignore:
8+
# Optional: Official actions have moving tags like v1;
9+
# if you use those, you don't need updates.
10+
- dependency-name: "actions/*"

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
- v*
10+
11+
jobs:
12+
standard:
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
runs-on: [ubuntu-latest, windows-latest, macos-latest]
17+
python:
18+
- 3.6
19+
- 3.7
20+
- 3.8
21+
- 3.9
22+
23+
name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}"
24+
runs-on: ${{ matrix.runs-on }}
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: Get history and tags for SCM versioning to work
30+
run: |
31+
git fetch --prune --unshallow
32+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
33+
34+
- name: Setup Python ${{ matrix.python }}
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: ${{ matrix.python }}
38+
architecture: 'x64'
39+
40+
- name: Get pip cache dir
41+
id: pip-cache
42+
run: |
43+
echo "::set-output name=dir::$(python -m pip cache dir)"
44+
45+
- name: Cache wheels
46+
uses: actions/cache@v2
47+
with:
48+
path: ${{ steps.pip-cache.outputs.dir }}
49+
key: ${{ runner.os }}-${{ matrix.python }}-pip-${{ hashFiles('setup.cfg', 'pyproject.toml') }}
50+
51+
- name: Prepare env
52+
run: |
53+
python -m pip install -U wheel coveralls
54+
55+
- name: Setup annotations on Linux
56+
if: runner.os == 'Linux'
57+
run: python -m pip install pytest-github-actions-annotate-failures
58+
59+
- name: Build and install package
60+
run: python -m pip install -e .[test]
61+
62+
- name: Run tests
63+
run: python -m pytest -v --cov=pylint_secure_coding_standard
64+
65+
- name: Coveralls.io
66+
run: coveralls --service=github
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
COVERALLS_FLAG_NAME: python-${{ matrix.python }}-${{ matrix.runs-on }}-x64
70+
COVERALLS_PARALLEL: true
71+
72+
finish:
73+
needs: standard
74+
runs-on: ubuntu-latest
75+
container: python:3-slim
76+
steps:
77+
- name: Coveralls Finished
78+
run: |
79+
pip3 install --upgrade coveralls
80+
coveralls --finish
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/codeql-analysis.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches: [ main ]
17+
pull_request:
18+
# The branches below must be a subset of the branches above
19+
branches: [ main ]
20+
schedule:
21+
- cron: '24 9 * * 0'
22+
23+
jobs:
24+
analyze:
25+
name: Analyze
26+
runs-on: ubuntu-latest
27+
permissions:
28+
actions: read
29+
contents: read
30+
security-events: write
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
language: [ 'python' ]
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v2
40+
41+
# Initializes the CodeQL tools for scanning.
42+
- name: Initialize CodeQL
43+
uses: github/codeql-action/init@v1
44+
with:
45+
languages: ${{ matrix.language }}
46+
# If you wish to specify custom queries, you can do so here or in a config file.
47+
# By default, queries listed here will override any specified in a config file.
48+
# Prefix the list here with "+" to use these queries and those in the config file.
49+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
50+
51+
- name: Autobuild
52+
uses: github/codeql-action/autobuild@v1
53+
54+
- name: Perform CodeQL Analysis
55+
uses: github/codeql-action/analyze@v1

.github/workflows/draft_release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: "Draft new release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release'
8+
required: true
9+
10+
jobs:
11+
new-release:
12+
name: "Draft a new release"
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Create release branch
18+
run: |
19+
git checkout -b release/${{ github.event.inputs.version }}
20+
21+
- name: Update changelog
22+
uses: thomaseizinger/[email protected]
23+
with:
24+
version: ${{ github.event.inputs.version }}
25+
26+
- name: Initialize mandatory git config
27+
run: |
28+
git config user.name "GitHub actions"
29+
git config user.email [email protected]
30+
- name: Commit changelog and manifest files
31+
id: make-commit
32+
run: |
33+
git add CHANGELOG.md
34+
git commit --message "Preparing release v${{ github.event.inputs.version }}"
35+
echo "::set-output name=commit::$(git rev-parse HEAD)"
36+
- name: Push new branch
37+
run: git push origin release/${{ github.event.inputs.version }}
38+
39+
- name: Create pull request
40+
uses: thomaseizinger/[email protected]
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
with:
44+
head: release/${{ github.event.inputs.version }}
45+
base: main
46+
title: Release version ${{ github.event.inputs.version }}
47+
reviewers: ${{ github.actor }}
48+
# Write a nice message to the user.
49+
# We are claiming things here based on the `publish-new-release.yml` workflow.
50+
# You should obviously adopt it to say the truth depending on your release workflow :)
51+
body: |
52+
Hi @${{ github.actor }}!
53+
This PR was created in response to a manual trigger of the release workflow here: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}.
54+
I've updated the changelog and bumped the versions in the manifest files in this commit: ${{ steps.make-commit.outputs.commit }}.
55+
Merging this PR will create a GitHub release and upload any assets that are created as part of the release build.

.github/workflows/format.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Format
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
- "v*"
9+
10+
jobs:
11+
pre-commit:
12+
name: Format and static analysis
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Get history and tags for SCM versioning to work
17+
run: |
18+
git fetch --prune --unshallow
19+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
20+
- uses: actions/setup-python@v2
21+
- uses: pre-commit/[email protected]
22+
with:
23+
# Slow hooks are marked with manual - slow is okay here, run them too
24+
extra_args: --hook-stage manual --all-files

.github/workflows/publish_release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: "Publish new release"
2+
3+
on:
4+
push:
5+
tags:
6+
- v[0-9]+.*
7+
pull_request:
8+
branches:
9+
- main
10+
types:
11+
- closed
12+
13+
jobs:
14+
release:
15+
name: Build wheels
16+
runs-on: ubuntu-latest
17+
if: startsWith(github.ref, 'refs/tags/') || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
22+
- name: Get history and tags for SCM versioning to work
23+
run: |
24+
git fetch --prune --unshallow
25+
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
26+
27+
- name: Extract version from tag name
28+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
29+
run: |
30+
TAG_NAME="${GITHUB_REF/refs\/tags\//}"
31+
VERSION=${TAG_NAME#v}
32+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
33+
34+
- name: Extract version from branch name (for release branches)
35+
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release/')
36+
run: |
37+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
38+
VERSION=${BRANCH_NAME#release/}
39+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
40+
41+
- name: Extract version from branch name (for hotfix branches)
42+
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'hotfix/')
43+
run: |
44+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
45+
VERSION=${BRANCH_NAME#hotfix/}
46+
echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV
47+
48+
- name: Set tag for setuptools-scm
49+
run: git tag v${RELEASE_VERSION} main
50+
51+
- name: Build wheel
52+
run: |
53+
python -m pip install build wheel
54+
python -m build --wheel --sdist
55+
56+
- name: Check metadata
57+
run: |
58+
python3 -m pip install twine --prefer-binary
59+
python3 -m twine check dist/*
60+
61+
# Code below inspired from this action:
62+
# - uses: taiki-e/create-gh-release-action@v1
63+
# with:
64+
# title: ProjectQ $tag
65+
# changelog: CHANGELOG.md
66+
# env:
67+
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
69+
- name: Create release
70+
env:
71+
target: x86_64-unknown-linux-musl
72+
parse_changelog_tag: v0.3.0
73+
changelog: CHANGELOG.md
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
run: |
76+
# https://github.com/taiki-e/parse-changelog
77+
curl -LsSf "https://github.com/taiki-e/parse-changelog/releases/download/${parse_changelog_tag}/parse-changelog-${target}.tar.gz" | tar xzf -
78+
notes=$(./parse-changelog "${changelog}" "${RELEASE_VERSION}")
79+
rm -f ./parse-changelog
80+
if [[ "${tag}" =~ ^v?[0-9\.]+-[a-zA-Z_0-9\.-]+(\+[a-zA-Z_0-9\.-]+)?$ ]]; then
81+
prerelease="--prerelease"
82+
fi
83+
gh release create "v${RELEASE_VERSION}" ${prerelease:-} --title "ProjectQ v${RELEASE_VERSION}" --notes "${notes:-}" dist/*
84+
85+
- name: Setup Python for Pypi upload
86+
uses: actions/setup-python@v2
87+
88+
- name: Publish standard package
89+
uses: pypa/gh-action-pypi-publish@release/v1
90+
with:
91+
user: __token__
92+
password: ${{ secrets.pypi_password }}
93+
packages_dir: dist/

.github/workflows/pull_request.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: PR
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
5+
6+
jobs:
7+
# Enforces the update of a changelog file on every pull request
8+
changelog:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- id: changelog-enforcer
14+
uses: dangoslen/changelog-enforcer@v2
15+
with:
16+
changeLogPath: 'CHANGELOG.md'
17+
skipLabels: 'Skip-Changelog'

0 commit comments

Comments
 (0)