Skip to content

Commit

Permalink
Merge pull request #41 from FullStackWithLawrence/next
Browse files Browse the repository at this point in the history
refactor for YT channel standard
  • Loading branch information
lpm0073 authored Dec 5, 2023
2 parents ff4916c + a57d6a4 commit 08e1bf4
Show file tree
Hide file tree
Showing 42 changed files with 905 additions and 800 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
# * text eol=lf
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# These are supported funding model platforms

github: lpm0073
patreon: lpm0073
github: FullStackWithLawrence
patreon: FullStackWithLawrence
18 changes: 9 additions & 9 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"
assignees:
- "lpm0073"
- "FullStackWithLawrence"
reviewers:
- "lpm0073"
- "FullStackWithLawrence"
- package-ecosystem: "pip"
directory: "/requirements/"
schedule:
interval: "monthly"
interval: "weekly"
labels:
- "dependencies"
- "python"
assignees:
- "lpm0073"
- "FullStackWithLawrence"
reviewers:
- "lpm0073"
- "FullStackWithLawrence"
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "monthly"
interval: "weekly"
labels:
- "dependencies"
- "javascript"
assignees:
- "lpm0073"
- "FullStackWithLawrence"
reviewers:
- "lpm0073"
- "FullStackWithLawrence"
25 changes: 0 additions & 25 deletions .github/workflows/checkPullRequest.yml

This file was deleted.

39 changes: 0 additions & 39 deletions .github/workflows/mergeMainNext.yml

This file was deleted.

102 changes: 102 additions & 0 deletions .github/workflows/precommitVersionBumps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
---
#------------------------------------------------------------------------------
# Lawrence McDaniel - https://lawrencemcdaniel.com
# Version Bump Workflow for .pre-commit-config.yaml
#
# This workflow runs on a cron schedule and checks for updates to the
# .pre-commit-config.yaml file. If updates are found, the workflow
# commits the changes to the next branch and pushes the changes to GitHub.
#
# This is a workaround for the fact that the pre-commit autoupdate command
# is not supported by Dependabot.
#------------------------------------------------------------------------------
name: pre-commit Version Bumps

on:
schedule:
- cron: "0 0 * * 3"
workflow_dispatch:

jobs:
evaluate_precommit_config:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Checkout next branch
run: |
git fetch
git checkout next
git pull origin next
- name: Cache NPM dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node
- name: Cache Python dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: locate site-packages path
shell: bash
run: |
echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
- name: Install pip
shell: bash
run: |
python -m pip install --upgrade pip
- name: Install dependencies
shell: bash
run: |
pip install -r ./requirements.txt
env:
SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}

- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20.9.0"

- name: Install npm dev dependencies
run: npm install

- name: Update .pre-commit-config.yaml
run: |
pre-commit autoupdate
- name: Check for unstaged changes
id: check_changes
run: |
if [[ -n "$(git status --porcelain .pre-commit-config.yaml)" ]]; then
echo "::set-output name=changes::true"
else
echo "::set-output name=changes::false"
fi
- name: Commit and push changes
if: steps.check_changes.outputs.changes == 'true'
shell: bash
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .pre-commit-config.yaml
git commit -m "chore: [gh] version bumps in .pre-commit-config.yaml [skip ci]"
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next
116 changes: 116 additions & 0 deletions .github/workflows/pullRequestController.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
---
#------------------------------------------------------------------------------
# Pull Request Workflow Controller.
#
# Triggers:
# - Called automatically on relevant actions performed on pull requests.
# - Can also be run manually by clicking the "Run workflow" button.
#
# Actions:
# - Use semantic release rules to determine if a new release will be published.
# - run Python tests, but only if Python-related files have changed.
# - run Terraform tests, but only if Terraform-related files have changed.
# - run ReactJS tests, but only if ReactJS-related files have changed.
# - run pre-commit hooks to ensure code is formatted correctly.
#
# To-Do:
# If a new release is to be published then we want to consider running QA tests
# to ensure formatting and documentation is correct.
#------------------------------------------------------------------------------
name: Pull Request Controller

on:
workflow_dispatch:
# GitHub Copilot: The `pull_request` and `pull_request_target` are two different
# event types in GitHub Actions that trigger workflows when activity related
# to pull requests occurs.
# - `pull_request`: This event triggers a workflow run whenever a pull
# request is opened, synchronized, or closed. The workflow runs in the context of the
# pull request, meaning it has access to the code and environment variables of the head
# branch of the pull request. This is safe for pull requests within the same repository,
# but for pull requests from a fork, this could potentially expose sensitive information.
#
# - `pull_request_target`: This event is similar to `pull_request`, but it runs in the context
# of the base of the pull request, rather than the head. This means it has access to the code
# and environment variables of the base branch, not the head branch. This is safer for
# pull requests from forks, as it prevents the fork from accessing sensitive information
# in the base repository. However, it means the workflow does not have access to the code
# in the pull request by default. If you need to access the code in the pull request,
# you can use the `actions/checkout` action with the `ref` input
# set to `github.event.pull_request.head.ref`.
#
# In general, use `pull_request` for workflows that need to access the code in the pull request,
# and `pull_request_target` for workflows that need to be safe for pull requests from forks.
pull_request_target:
types: [opened, synchronize]
paths:
- "**.py"
- "**.requirements.txt"
- "**.package.json"
- "./secure_logger/**"

env:
python-version: "3.11"

jobs:
check_for_pending_release:
name: test-semantic-release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Semantic Release
uses: cycjimmy/semantic-release-action@v4
id: semantic
with:
dry_run: true
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
extra_plugins: |
@semantic-release/git
@semantic-release/changelog
env:
GITHUB_TOKEN: ${{ secrets.PAT }}

- name: Test Outputs
if: steps.semantic.outputs.new_release_published == 'true'
run: |
echo ${{ steps.semantic.outputs.new_release_version }}
echo ${{ steps.semantic.outputs.new_release_major_version }}
echo ${{ steps.semantic.outputs.new_release_minor_version }}
echo ${{ steps.semantic.outputs.new_release_patch_version }}
python_tests:
needs: check_for_pending_release
runs-on: ubuntu-latest

steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v4

- name: Check for changed files
id: file_changes
run: |
echo "::set-output name=files_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '\.py$' || true)"
echo "::set-output name=requirements_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'requirements.txt$' || true)"
- name: Run Python tests
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
uses: ./.github/actions/tests/python
with:
python-version: "${{ env.python-version}}"
Loading

0 comments on commit 08e1bf4

Please sign in to comment.