Skip to content

Commit

Permalink
template updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael R. Blanton committed May 11, 2024
1 parent becf65b commit 3d210a0
Show file tree
Hide file tree
Showing 21 changed files with 315 additions and 1,495 deletions.
3 changes: 2 additions & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changes here will be overwritten by Copier
_commit: v1.4.3
_commit: v2.0.1
_src_path: gh:lincc-frameworks/python-project-template
author_email: [email protected]
author_name: Michael R. Blanton
custom_install: false
package_name: kcorrect
project_license: BSD
project_name: kcorrect
project_organization: blanton144
26 changes: 10 additions & 16 deletions .github/workflows/asv-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,24 @@ env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks

jobs:

consecutiveness:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

steps:
- name: Set workflows on main to run consecutively
uses: mktcode/consecutive-workflow-action@eb43c6b5852dd0e33efa797a1817196d06daa4b2
with:
token: ${{ secrets.GITHUB_TOKEN }}
jobs:

setup-python:
runs-on: ubuntu-latest
needs: consecutiveness

steps:
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"

Expand All @@ -52,12 +46,12 @@ jobs:

steps:
- name: Checkout main branch of the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
Expand All @@ -66,7 +60,7 @@ jobs:
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv==0.5.1 virtualenv tabulate
pip install asv==0.6.1 virtualenv tabulate
- name: Configure git
run: |
Expand All @@ -86,7 +80,7 @@ jobs:
fi
- name: Run ASV for the main branch
run: asv run ALL --skip-existing
run: asv run ALL --skip-existing --verbose || true

- name: Submit new results to the "benchmarks" branch
uses: JamesIves/github-pages-deploy-action@v4
Expand Down
35 changes: 24 additions & 11 deletions .github/workflows/asv-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ name: Run benchmarks nightly job
on:
schedule:
- cron: 45 6 * * *

workflow_dispatch:

env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks
Expand All @@ -24,38 +25,52 @@ jobs:

steps:
- name: Checkout main branch of the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv==0.5.1 virtualenv
pip install asv==0.6.1 virtualenv
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes

- name: Fetch previous results from the "benchmarks" branch
run: |
if git ls-remote --exit-code origin benchmarks > /dev/null 2>&1; then
git merge origin/benchmarks \
--allow-unrelated-histories \
--no-commit
mv ../_results .
fi
- name: Get nightly dates under comparison
id: nightly-dates
run: |
echo "yesterday=$(date -d yesterday +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "today=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- name: Use last nightly commit hash from cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.WORKING_DIR }}
key: nightly-results-${{ steps.nightly-dates.outputs.yesterday }}
Expand All @@ -64,17 +79,15 @@ jobs:
run: |
HASH_FILE=${{ env.NIGHTLY_HASH_FILE }}
CURRENT_HASH=${{ github.sha }}
if [ -f $HASH_FILE ]; then
PREV_HASH=$(cat $HASH_FILE)
asv continuous $PREV_HASH $CURRENT_HASH || true
asv compare $PREV_HASH $CURRENT_HASH --sort ratio
asv continuous $PREV_HASH $CURRENT_HASH --verbose || true
asv compare $PREV_HASH $CURRENT_HASH --sort ratio --verbose
fi
echo $CURRENT_HASH > $HASH_FILE
- name: Update last nightly hash in cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.WORKING_DIR }}
key: nightly-results-${{ steps.nightly-dates.outputs.today }}
149 changes: 64 additions & 85 deletions .github/workflows/asv-pr.yml
Original file line number Diff line number Diff line change
@@ -1,107 +1,86 @@
# This workflow will run benchmarks with airspeed velocity (asv) for pull requests.
# It will compare the performance of the main branch with the performance of the merge
# with the new changes and publish a comment with this assessment.

name: Run ASV benchmarks for PR
# with the new changes. It then publishes a comment with this assessment by triggering
# the publish-benchmarks-pr workflow.
# Based on https://securitylab.github.com/research/github-actions-preventing-pwn-requests/.
name: Run benchmarks for PR

on:
pull_request:
branches: [ main ]

env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
env:
PYTHON_VERSION: "3.10"
WORKING_DIR: ${{ github.workspace }}/benchmarks
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts

jobs:
setup-python:
runs-on: ubuntu-latest

steps:
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4
with:
python-version: "${{ env.PYTHON_VERSION }}"

- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
asv-pr:
runs-on: ubuntu-latest
needs: setup-python

permissions:
actions: read
pull-requests: write

defaults:
run:
working-directory: ${{ env.WORKING_DIR }}

steps:
- name: Checkout PR branch of the repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}

- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv==0.5.1 virtualenv tabulate lf-asv-formatter
- name: Get current job logs URL
uses: Tiryoh/gha-jobid-action@v0
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: ${{ github.job }}

- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes

- name: Run comparison of PR against main branch
run: |
git remote add upstream https://github.com/${{ github.repository }}.git
git fetch upstream
asv continuous upstream/main HEAD || true
asv compare upstream/main HEAD --sort ratio | tee output
python -m lf_asv_formatter
printf "\n\nClick [here]($STEP_URL) to view all benchmarks." >> output
env:
STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:8:1"

- name: Publish comment to PR
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const path = require('path');
const workingDir = process.env.WORKING_DIR;
try {
process.chdir(workingDir);
const comment = fs.readFileSync('output', 'utf-8');
const { data } = await github.rest.issues.createComment({
...context.repo,
issue_number: context.issue.number,
body: comment,
});
console.log('Comment published:', data.html_url);
} catch (err) {
console.error(err);
}
- name: Checkout PR branch of the repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Display Workflow Run Information
run: |
echo "Workflow Run ID: ${{ github.run_id }}"
- name: Cache Python ${{ env.PYTHON_VERSION }}
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: python-${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
sudo apt-get update
python -m pip install --upgrade pip
pip install asv==0.6.1 virtualenv tabulate lf-asv-formatter
- name: Make artifacts directory
run: mkdir -p ${{ env.ARTIFACTS_DIR }}
- name: Save pull request number
run: echo ${{ github.event.pull_request.number }} > ${{ env.ARTIFACTS_DIR }}/pr
- name: Get current job logs URL
uses: Tiryoh/gha-jobid-action@v1
id: jobs
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
job_name: ${{ github.job }}
- name: Create ASV machine config file
run: asv machine --machine gh-runner --yes
- name: Save comparison of PR against main branch
run: |
git remote add upstream https://github.com/${{ github.repository }}.git
git fetch upstream
asv continuous upstream/main HEAD --verbose || true
asv compare upstream/main HEAD --sort ratio --verbose | tee output
python -m lf_asv_formatter --asv_version "$(echo asv --version)"
printf "\n\nClick [here]($STEP_URL) to view all benchmarks." >> output
mv output ${{ env.ARTIFACTS_DIR }}
env:
STEP_URL: "${{ steps.jobs.outputs.html_url }}#step:11:1"
- name: Upload artifacts (PR number and benchmarks output)
uses: actions/upload-artifact@v4
with:
name: benchmark-artifacts
path: ${{ env.ARTIFACTS_DIR }}
4 changes: 2 additions & 2 deletions .github/workflows/build-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
Expand Down
35 changes: 0 additions & 35 deletions .github/workflows/linting.yml

This file was deleted.

Loading

0 comments on commit 3d210a0

Please sign in to comment.