-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new version of .github workflows and actions (namely around the…
… autotagging)
- Loading branch information
Showing
10 changed files
with
275 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name : 'Increment Tag - Dev' | ||
description: 'Increment Tag - Dev' | ||
|
||
inputs: | ||
package_name: | ||
description: 'Package name for coverage' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: List all branches | ||
shell: bash | ||
run: git branch -a | ||
|
||
- name: Checkout dev branch | ||
shell: bash | ||
run: | | ||
git checkout dev || (git checkout -b dev && git push -u origin dev) | ||
- name: Set up Git user | ||
shell: bash | ||
run: | | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
- name: Fetch all tags | ||
shell: bash | ||
run: git fetch --tags | ||
|
||
- name: Find and increment latest tag | ||
shell: bash | ||
id: latest_tag | ||
run: | | ||
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
echo "Latest tag: $LATEST_TAG" | ||
# Extract just the version part and increment it | ||
VERSION_PART=$(echo $LATEST_TAG | sed 's/^v//') | ||
MAJOR=$(echo $VERSION_PART | cut -d. -f1) | ||
MINOR=$(echo $VERSION_PART | cut -d. -f2) | ||
PATCH=$(echo $VERSION_PART | cut -d. -f3) | ||
NEW_PATCH=$((PATCH + 1)) | ||
NEW_TAG="v$MAJOR.$MINOR.$NEW_PATCH" | ||
echo "New tag: $NEW_TAG" | ||
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | ||
- name: Update README badge | ||
shell: bash | ||
run: | | ||
sed -i "s/release-v[0-9]*\.[0-9]*\.[0-9]*/release-$NEW_TAG/" README.md | ||
- name: Update Version File (root) | ||
shell: bash | ||
run: | | ||
echo $NEW_TAG | sed 's/refs\/tags\///' > ./${{ inputs.package_name }}/version | ||
- name: Commit and push changes | ||
shell: bash | ||
run: | | ||
git add README.md ./${{ inputs.package_name }}/version | ||
git commit -m "Update release badge and version file" | ||
git push origin dev # Push to the 'dev' branch | ||
- name: Tag new version | ||
shell: bash | ||
run: | | ||
NEW_TAG=${{ env.NEW_TAG }} | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git tag $NEW_TAG | ||
git push origin $NEW_TAG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name : 'Increment Tag - Main' | ||
description: 'Increment Tag - Main' | ||
|
||
inputs: | ||
package_name: | ||
description: 'Package name for coverage' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 # updated to v2 | ||
with: | ||
ref: 'main' # Check out the 'main' branch | ||
fetch-depth: 0 # Fetch all history for .Git info | ||
|
||
- name: Update Main Branch | ||
shell: bash | ||
run: | | ||
git pull origin main | ||
- name: Set up Git user | ||
shell: bash | ||
run: | | ||
git config --global user.name 'GitHub Actions' | ||
git config --global user.email '[email protected]' | ||
- name: Fetch all tags | ||
shell: bash | ||
run: git fetch --tags | ||
|
||
- name: Find and increment latest tag | ||
shell: bash | ||
id: latest_tag | ||
run: | | ||
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) | ||
echo "Latest tag: $LATEST_TAG" | ||
# Extract just the version part and increment it | ||
VERSION_PART=$(echo $LATEST_TAG | sed 's/^v//') | ||
MAJOR=$(echo $VERSION_PART | cut -d. -f1) | ||
Z_PART=$(echo $VERSION_PART | cut -d. -f2) | ||
NEW_Z=$((Z_PART + 1)) | ||
NEW_TAG="v$MAJOR.$NEW_Z.0" | ||
echo "New tag: $NEW_TAG" | ||
echo "NEW_TAG=$NEW_TAG" >> $GITHUB_ENV | ||
- name: Update README badge | ||
shell: bash | ||
run: | | ||
sed -i "s/release-v[0-9]*\.[0-9]*\.[0-9]*/release-$NEW_TAG/" README.md | ||
- name: Update Version File (root) | ||
shell: bash | ||
run: | | ||
echo $NEW_TAG > ./${{ inputs.package_name }}/version | ||
- name: Commit and push changes | ||
shell: bash | ||
run: | | ||
git add README.md ./${{ inputs.package_name }}/version | ||
git commit -m "Update release badge and version file" | ||
git push origin main # Push to the 'main' branch | ||
- name: Tag new version | ||
shell: bash | ||
run: | | ||
NEW_TAG=${{ env.NEW_TAG }} | ||
git tag $NEW_TAG | ||
git push origin $NEW_TAG | ||
- name: Update Dev branch | ||
shell: bash | ||
run: | | ||
git checkout dev | ||
git merge main | ||
git push origin dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name : Install Dependencies | ||
description: 'Install Dependencies' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.x | ||
- name: Cache pip dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
shell: bash | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install -e . | ||
- name: Configure Playwright | ||
shell: bash | ||
run: | | ||
playwright install chromium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Run Python Tests | ||
description: 'Run Python Tests' | ||
|
||
inputs: | ||
codecov_token: | ||
description: 'CodeCov access token' | ||
required: true | ||
package_name: | ||
description: 'Package name for coverage' | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Run tests with pytest (with coverage) | ||
shell: bash | ||
run: | | ||
coverage run --source=${{ inputs.package_name }} -m pytest -v -s --durations=0 --ignore=tests_* tests | ||
- name: Print coverage report | ||
shell: bash | ||
run: | | ||
coverage report -m | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
CODECOV_TOKEN : ${{ inputs.codecov_token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Increment Tag - Dev branch | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Run Unit Tests"] | ||
branches: [dev] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
increment-tag-dev: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 # | ||
- name: Increment Tag (for DEV) | ||
uses: ./.github/actions/increment-tag-dev | ||
with: | ||
package_name: ${{ secrets.PACKAGE_NAME }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Increment Tag - Main branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
increment-tag-main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Increment Tag - Main | ||
uses: ./.github/actions/increment-tag-main | ||
with: | ||
package_name: ${{ secrets.PACKAGE_NAME }} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name : Run Unit Tests | ||
on: | ||
push | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Dependencies | ||
uses: ./.github/actions/install-dependencies | ||
|
||
- name: Run Unit Tests | ||
uses: ./.github/actions/run-unit-tests | ||
with: | ||
codecov_token : ${{ secrets.CODECOV_TOKEN }} | ||
package_name : ${{ secrets.PACKAGE_NAME }} | ||
|