Skip to content

Commit 08e1bf4

Browse files
authored
Merge pull request #41 from FullStackWithLawrence/next
refactor for YT channel standard
2 parents ff4916c + a57d6a4 commit 08e1bf4

42 files changed

Lines changed: 905 additions & 800 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
# * text eol=lf

.github/FUNDING.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# These are supported funding model platforms
22

3-
github: lpm0073
4-
patreon: lpm0073
3+
github: FullStackWithLawrence
4+
patreon: FullStackWithLawrence

.github/dependabot.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ updates:
33
- package-ecosystem: "github-actions"
44
directory: "/"
55
schedule:
6-
interval: "monthly"
6+
interval: "weekly"
77
assignees:
8-
- "lpm0073"
8+
- "FullStackWithLawrence"
99
reviewers:
10-
- "lpm0073"
10+
- "FullStackWithLawrence"
1111
- package-ecosystem: "pip"
1212
directory: "/requirements/"
1313
schedule:
14-
interval: "monthly"
14+
interval: "weekly"
1515
labels:
1616
- "dependencies"
1717
- "python"
1818
assignees:
19-
- "lpm0073"
19+
- "FullStackWithLawrence"
2020
reviewers:
21-
- "lpm0073"
21+
- "FullStackWithLawrence"
2222
- package-ecosystem: "npm"
2323
directory: "/"
2424
schedule:
25-
interval: "monthly"
25+
interval: "weekly"
2626
labels:
2727
- "dependencies"
2828
- "javascript"
2929
assignees:
30-
- "lpm0073"
30+
- "FullStackWithLawrence"
3131
reviewers:
32-
- "lpm0073"
32+
- "FullStackWithLawrence"

.github/workflows/checkPullRequest.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/mergeMainNext.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
#------------------------------------------------------------------------------
3+
# Lawrence McDaniel - https://lawrencemcdaniel.com
4+
# Version Bump Workflow for .pre-commit-config.yaml
5+
#
6+
# This workflow runs on a cron schedule and checks for updates to the
7+
# .pre-commit-config.yaml file. If updates are found, the workflow
8+
# commits the changes to the next branch and pushes the changes to GitHub.
9+
#
10+
# This is a workaround for the fact that the pre-commit autoupdate command
11+
# is not supported by Dependabot.
12+
#------------------------------------------------------------------------------
13+
name: pre-commit Version Bumps
14+
15+
on:
16+
schedule:
17+
- cron: "0 0 * * 3"
18+
workflow_dispatch:
19+
20+
jobs:
21+
evaluate_precommit_config:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
persist-credentials: false
28+
29+
- name: Checkout next branch
30+
run: |
31+
git fetch
32+
git checkout next
33+
git pull origin next
34+
35+
- name: Cache NPM dependencies
36+
uses: actions/cache@v3
37+
with:
38+
path: ~/.npm
39+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-node
42+
43+
- name: Cache Python dependencies
44+
uses: actions/cache@v3
45+
with:
46+
path: ~/.cache/pip
47+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
48+
restore-keys: |
49+
${{ runner.os }}-pip
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: "3.11"
55+
56+
- name: locate site-packages path
57+
shell: bash
58+
run: |
59+
echo "SITE_PACKAGES_PATH=$(python -c 'import site; print(site.getsitepackages()[0])')" >> $GITHUB_ENV
60+
61+
- name: Install pip
62+
shell: bash
63+
run: |
64+
python -m pip install --upgrade pip
65+
66+
- name: Install dependencies
67+
shell: bash
68+
run: |
69+
pip install -r ./requirements.txt
70+
env:
71+
SITE_PACKAGES_PATH: ${{ env.SITE_PACKAGES_PATH }}
72+
73+
- name: Setup Node.js environment
74+
uses: actions/setup-node@v4
75+
with:
76+
node-version: "20.9.0"
77+
78+
- name: Install npm dev dependencies
79+
run: npm install
80+
81+
- name: Update .pre-commit-config.yaml
82+
run: |
83+
pre-commit autoupdate
84+
85+
- name: Check for unstaged changes
86+
id: check_changes
87+
run: |
88+
if [[ -n "$(git status --porcelain .pre-commit-config.yaml)" ]]; then
89+
echo "::set-output name=changes::true"
90+
else
91+
echo "::set-output name=changes::false"
92+
fi
93+
94+
- name: Commit and push changes
95+
if: steps.check_changes.outputs.changes == 'true'
96+
shell: bash
97+
run: |
98+
git config --local user.email "action@github.com"
99+
git config --local user.name "GitHub Action"
100+
git add .pre-commit-config.yaml
101+
git commit -m "chore: [gh] version bumps in .pre-commit-config.yaml [skip ci]"
102+
git push https://${{ secrets.PAT }}@github.com/${{ github.repository }}.git HEAD:next
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
#------------------------------------------------------------------------------
3+
# Pull Request Workflow Controller.
4+
#
5+
# Triggers:
6+
# - Called automatically on relevant actions performed on pull requests.
7+
# - Can also be run manually by clicking the "Run workflow" button.
8+
#
9+
# Actions:
10+
# - Use semantic release rules to determine if a new release will be published.
11+
# - run Python tests, but only if Python-related files have changed.
12+
# - run Terraform tests, but only if Terraform-related files have changed.
13+
# - run ReactJS tests, but only if ReactJS-related files have changed.
14+
# - run pre-commit hooks to ensure code is formatted correctly.
15+
#
16+
# To-Do:
17+
# If a new release is to be published then we want to consider running QA tests
18+
# to ensure formatting and documentation is correct.
19+
#------------------------------------------------------------------------------
20+
name: Pull Request Controller
21+
22+
on:
23+
workflow_dispatch:
24+
# GitHub Copilot: The `pull_request` and `pull_request_target` are two different
25+
# event types in GitHub Actions that trigger workflows when activity related
26+
# to pull requests occurs.
27+
# - `pull_request`: This event triggers a workflow run whenever a pull
28+
# request is opened, synchronized, or closed. The workflow runs in the context of the
29+
# pull request, meaning it has access to the code and environment variables of the head
30+
# branch of the pull request. This is safe for pull requests within the same repository,
31+
# but for pull requests from a fork, this could potentially expose sensitive information.
32+
#
33+
# - `pull_request_target`: This event is similar to `pull_request`, but it runs in the context
34+
# of the base of the pull request, rather than the head. This means it has access to the code
35+
# and environment variables of the base branch, not the head branch. This is safer for
36+
# pull requests from forks, as it prevents the fork from accessing sensitive information
37+
# in the base repository. However, it means the workflow does not have access to the code
38+
# in the pull request by default. If you need to access the code in the pull request,
39+
# you can use the `actions/checkout` action with the `ref` input
40+
# set to `github.event.pull_request.head.ref`.
41+
#
42+
# In general, use `pull_request` for workflows that need to access the code in the pull request,
43+
# and `pull_request_target` for workflows that need to be safe for pull requests from forks.
44+
pull_request_target:
45+
types: [opened, synchronize]
46+
paths:
47+
- "**.py"
48+
- "**.requirements.txt"
49+
- "**.package.json"
50+
- "./secure_logger/**"
51+
52+
env:
53+
python-version: "3.11"
54+
55+
jobs:
56+
check_for_pending_release:
57+
name: test-semantic-release
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Semantic Release
64+
uses: cycjimmy/semantic-release-action@v4
65+
id: semantic
66+
with:
67+
dry_run: true
68+
branches: |
69+
[
70+
'+([0-9])?(.{+([0-9]),x}).x',
71+
'main',
72+
'next',
73+
'next-major',
74+
{
75+
name: 'beta',
76+
prerelease: true
77+
},
78+
{
79+
name: 'alpha',
80+
prerelease: true
81+
}
82+
]
83+
extra_plugins: |
84+
@semantic-release/git
85+
@semantic-release/changelog
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.PAT }}
88+
89+
- name: Test Outputs
90+
if: steps.semantic.outputs.new_release_published == 'true'
91+
run: |
92+
echo ${{ steps.semantic.outputs.new_release_version }}
93+
echo ${{ steps.semantic.outputs.new_release_major_version }}
94+
echo ${{ steps.semantic.outputs.new_release_minor_version }}
95+
echo ${{ steps.semantic.outputs.new_release_patch_version }}
96+
97+
python_tests:
98+
needs: check_for_pending_release
99+
runs-on: ubuntu-latest
100+
101+
steps:
102+
- name: Checkout code
103+
id: checkout
104+
uses: actions/checkout@v4
105+
106+
- name: Check for changed files
107+
id: file_changes
108+
run: |
109+
echo "::set-output name=files_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep '\.py$' || true)"
110+
echo "::set-output name=requirements_changed::$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep 'requirements.txt$' || true)"
111+
112+
- name: Run Python tests
113+
if: steps.file_changes.outputs.files_changed != '' || steps.file_changes.outputs.requirements_changed != ''
114+
uses: ./.github/actions/tests/python
115+
with:
116+
python-version: "${{ env.python-version}}"

0 commit comments

Comments
 (0)