Compare commits

...

105 Commits

Author SHA1 Message Date
hangpersonal f77fb3c669 Merge pull request 'Pull request test' (#4) from pull_request_test into main
Reviewed-on: #4
2025-10-19 19:08:15 -07:00
hangpersonal c533cda173 Pull request test
Pat Bump Tag / build (pull_request) Failing after 28s
2025-10-19 19:06:14 -07:00
hangpersonal ffe3223292 Update REDME.md 2025-10-19 18:56:41 -07:00
hangpersonal 47757c3b8c Add .gitea/workflows/*.yaml 2025-10-19 18:55:04 -07:00
hangpersonal 6d42eabbc6 Merge pull request 'Pull request demo' (#3) from pull_request_demo into main
Reviewed-on: #3
2025-10-19 15:46:41 -07:00
hangpersonal 205bb350f2 Pull request demo
Pat Bump Tag / build (pull_request) Failing after 10s
2025-10-19 15:45:36 -07:00
hangpersonal 6bd405d9f0 Add .gitea/workflows/*.yaml 2025-10-19 15:44:27 -07:00
hangpersonal 3bd8b97ba9 Add .gitea/workflows/*.yaml 2025-10-19 15:42:40 -07:00
hangpersonal 361da95b47 Merge pull request 'Pull request demo' (#2) from pull_request_demo into main
Reviewed-on: #2
2025-10-19 13:51:14 -07:00
hangpersonal 1b9ca9e31e Pull request demo
Pat Bump Tag / build (pull_request) Failing after 8s
2025-10-19 13:23:39 -07:00
hangpersonal a16e742b48 Add .gitea/workflows/*.yaml 2025-10-19 13:21:40 -07:00
hangpersonal b9cde3acc1 Merge pull request 'Pull request demo' (#1) from pull_request_demo into main
Reviewed-on: #1
2025-10-19 12:57:12 -07:00
hangpersonal 696bd8993b Pull request demo
Pat Bump Tag / build (pull_request) Failing after 28s
2025-10-19 12:50:27 -07:00
hangpersonal a50c2a58c6 Add .gitea/workflows/*.yaml 2025-10-19 12:49:03 -07:00
hangpersonal 6a30911696 Attempt to write 2025-10-19 18:31:47 +00:00
hangpersonal 1082bce072 Attempt to write 2025-10-19 18:28:59 +00:00
hangpersonal 0b8b71bdfc Add .gitea/workflows/*.yaml 2025-10-19 11:28:13 -07:00
hangpersonal f2591496ab Add .gitea/workflows/*.yaml 2025-10-19 10:03:24 -07:00
hangpersonal 2843d7c765 Add .gitea/workflows/*.yaml 2025-10-19 09:31:26 -07:00
hangpersonal f22df7b6bf Add .gitea/workflows/*.yaml 2025-10-19 09:07:57 -07:00
hangpersonal 9aed5a1f23 Add .gitea/workflows/*.yaml 2025-10-19 00:38:30 -07:00
hangpersonal 3269f2f461 Add .gitea/workflows/*.yaml 2025-10-18 23:54:27 -07:00
hangpersonal 7f7020f53c Add .gitea/workflows/*.yaml 2025-10-18 23:45:52 -07:00
hangpersonal 727cee9e54 Add .gitea/workflows/*.yaml 2025-10-18 23:29:49 -07:00
hangpersonal 4608d136e6 Add .gitea/workflows/*.yaml 2025-10-18 23:23:20 -07:00
hangpersonal c78a43048e Add .gitea/workflows/*.yaml 2025-10-18 23:02:39 -07:00
hangpersonal e6afe787a6 Add .gitea/workflows/*.yaml 2025-10-18 22:44:01 -07:00
hangpersonal 51709470b9 Add .gitea/workflows/*.yaml 2025-10-18 22:39:59 -07:00
hangpersonal f2769fa2f4 Add .gitea/workflows/*.yaml 2025-10-18 22:31:44 -07:00
hangpersonal 7197043d8a Add .gitea/workflows/*.yaml 2025-10-18 22:11:15 -07:00
hangpersonal c867e96806 Add .gitea/workflows/*.yaml 2025-10-18 21:14:17 -07:00
hangpersonal c4bd57ba93 Add .gitea/workflows/*.yaml 2025-10-18 20:57:21 -07:00
hangpersonal 0ac7387f38 Add .gitea/workflows/*.yaml 2025-10-18 20:32:35 -07:00
hangpersonal 17c32c00d3 Add .gitea/workflows/*.yaml 2025-10-18 20:13:26 -07:00
hangpersonal a20407ef42 Add .gitea/workflows/*.yaml 2025-10-18 17:05:28 -07:00
hangpersonal bf8736f9a5 Add .gitea/workflows/*.yaml 2025-10-18 16:51:32 -07:00
hangpersonal cc176da1ed Add .gitea/workflows/*.yaml 2025-10-18 16:42:03 -07:00
hangpersonal 391cd397f0 Add .gitea/workflows/*.yaml 2025-10-18 16:32:39 -07:00
hangpersonal 7e858447b6 Add .gitea/workflows/*.yaml 2025-10-18 16:24:05 -07:00
hangpersonal 87369f5924 Add .gitea/workflows/*.yaml 2025-10-18 16:16:57 -07:00
hangpersonal 1cebfa83c3 Add .gitea/workflows/*.yaml 2025-10-18 15:29:30 -07:00
hangpersonal 091411890b Add .gitea/workflows/*.yaml 2025-10-18 15:10:44 -07:00
hangpersonal ffe70f38aa Add .gitea/workflows/*.yaml 2025-10-18 15:01:14 -07:00
hangpersonal 3abaedccf5 Add .gitea/workflows/*.yaml 2025-10-18 14:35:09 -07:00
hangpersonal eb777c2486 Add .gitea/workflows/*.yaml 2025-10-18 12:56:22 -07:00
hangpersonal 13ab374302 Add .gitea/workflows/*.yaml 2025-10-18 12:49:36 -07:00
hangpersonal 8d81f41a9f Add .gitea/workflows/*.yaml 2025-10-18 12:33:40 -07:00
hangpersonal d635a0ceed Add .gitea/workflows/*.yaml 2025-10-18 12:24:19 -07:00
hangpersonal 9f45610da4 Add .gitea/workflows/*.yaml 2025-10-18 02:01:56 -07:00
hangpersonal 676c2b0624 Add .gitea/workflows/*.yaml 2025-10-18 01:36:56 -07:00
hangpersonal 7c19e34337 Add .gitea/workflows/*.yaml 2025-10-18 01:30:43 -07:00
hangpersonal 89d2950754 Add .gitea/workflows/*.yaml 2025-10-18 01:20:16 -07:00
hangpersonal 29a8ab5115 Add .gitea/workflows/*.yaml 2025-10-18 01:06:37 -07:00
hangpersonal b65f488cf2 Add .gitea/workflows/*.yaml 2025-10-18 00:37:07 -07:00
hangpersonal c5a76614f4 Add .gitea/workflows/*.yaml 2025-10-18 00:35:31 -07:00
hangpersonal 0638a82a8d Add .gitea/workflows/*.yaml 2025-10-18 00:12:42 -07:00
hangpersonal 2719d95738 Add .gitea/workflows/*.yaml 2025-10-18 00:10:26 -07:00
hangpersonal 19bcb361c0 Add .gitea/workflows/*.yaml 2025-10-17 21:04:58 -07:00
hangpersonal c57f058e99 Add .gitea/workflows/*.yaml 2025-10-17 21:02:57 -07:00
hangpersonal 3f964846f8 Add .gitea/workflows/*.yaml 2025-10-17 21:00:30 -07:00
hangpersonal dce2c5af71 Add .gitea/workflows/*.yaml 2025-10-17 20:56:19 -07:00
hangpersonal b4e01e369e Add .gitea/workflows/*.yaml 2025-10-17 20:54:03 -07:00
hangpersonal e7dc599785 Add .gitea/workflows/*.yaml 2025-10-17 20:48:56 -07:00
hangpersonal 184e12e0b8 Add .gitea/workflows/*.yaml 2025-10-17 20:45:53 -07:00
hangpersonal 61bc3904b3 Add .gitea/workflows/*.yaml 2025-10-17 20:43:19 -07:00
hangpersonal 8cc758ad73 Add .gitea/workflows/*.yaml 2025-10-17 20:37:44 -07:00
hangpersonal 295c346094 Add .gitea/workflows/*.yaml 2025-10-17 20:09:34 -07:00
hangpersonal 5e5f21993e Add .gitea/workflows/*.yaml 2025-10-17 20:04:45 -07:00
hangpersonal 01ae91e8d5 Add .gitea/workflows/*.yaml 2025-10-17 20:02:46 -07:00
hangpersonal 401cf0a051 Add .gitea/workflows/*.yaml 2025-10-17 20:00:49 -07:00
Hang Cui 33bc257130 Update repo 2025-10-17 16:19:00 -07:00
Hang Cui 51213a40c8 Update repo 2025-10-17 16:15:20 -07:00
Hang Cui 04a26b5a4a Update repo 2025-10-17 16:09:46 -07:00
Hang Cui b484044697 Update repo 2025-10-17 16:03:21 -07:00
Hang Cui 9ee923c03c Update repo 2025-10-17 16:02:26 -07:00
Hang Cui a29d943dc9 Update repo 2025-10-17 15:55:32 -07:00
Hang Cui 9276b743c4 Update repo 2025-10-17 15:52:33 -07:00
Hang Cui dbe056871d Update repo 2025-10-17 15:48:46 -07:00
Hang Cui 61b44cd971 Update repo 2025-10-17 15:46:46 -07:00
Hang Cui 96e8939def Update repo
Upload Artifact Example / build-and-upload (push) Successful in 8s
2025-10-17 15:40:06 -07:00
Hang Cui 0bb2b25ecb Update repo 2025-10-17 15:32:29 -07:00
Hang Cui 1fc2b87c2b Update repo 2025-10-17 15:21:02 -07:00
Hang Cui fda0ea273c Update repo 2025-10-17 15:14:12 -07:00
Hang Cui b74e27d5b1 Update repo 2025-10-17 15:08:01 -07:00
Hang Cui 120b188235 Update repo 2025-10-17 15:05:31 -07:00
Hang Cui 3c9b43f368 Update repo 2025-10-17 14:58:18 -07:00
Hang Cui b3d66ab849 Update repo 2025-10-17 14:54:42 -07:00
Hang Cui b20c95a7b9 Update repo 2025-10-17 14:46:32 -07:00
Hang Cui 47ee65301d Update repo 2025-10-17 14:44:03 -07:00
Hang Cui 5763ea63e7 Update repo 2025-10-17 14:38:21 -07:00
Hang Cui 46c127dc50 Update repo 2025-10-17 14:20:36 -07:00
Hang Cui c3d95810bb Update .gitea/workflow/*.yaml 2025-10-17 14:18:34 -07:00
Hang Cui 2145f94f18 Update .gitea/workflow/*.yaml 2025-10-17 14:15:38 -07:00
Hang Cui 4d30f024a4 Update workflows *.yaml 2025-10-17 14:07:12 -07:00
Hang Cui a87080f9c4 Add backend directory 2025-10-17 14:05:14 -07:00
Hang Cui e9bb3b0a7f Update workflows *.yaml 2025-10-17 13:11:26 -07:00
Hang Cui 04de1f4a23 Update workflows *.yaml 2025-10-17 13:09:18 -07:00
Hang Cui 9c40e143b0 Update workflows *.yaml 2025-10-17 12:59:46 -07:00
Hang Cui 9da21e6311 Update workflows *.yaml 2025-10-17 12:30:38 -07:00
Hang Cui 6a6ddacb9e Update .gitea/workflow/*.yaml 2025-10-17 10:44:28 -07:00
Hang Cui fac212e278 Update .gitea/workflow/*.yaml 2025-10-17 10:19:58 -07:00
hangpersonal 7eb71757ea Update *.yaml 2025-10-16 23:58:47 -07:00
hangpersonal 7101ddb38c Update *.yaml 2025-10-16 23:04:31 -07:00
hangpersonal 2c24d17eb1 Update manual_trigger.yaml
CI Workflow / build-and-test (push) Successful in 1m13s
Docker Build / docker (push) Successful in 16s
2025-10-16 22:57:28 -07:00
hangpersonal e0002a1d99 Add manual_trigger.yaml
CI Workflow / build-and-test (push) Successful in 2m4s
Docker Build / docker (push) Successful in 49s
2025-10-16 21:55:46 -07:00
36 changed files with 882 additions and 131 deletions
+37
View File
@@ -0,0 +1,37 @@
name: Conditional Steps # Name of workflow
on:
workflow_dispatch:
jobs:
example_job:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Exit Code 0
id: successful_step
run: |
echo "exit code 0"
exit 0 # Success (exit code 0)
shell: bash # If you want you can change the shell per step
- name: Step 2 - Execute If Previous Succeeded
# The syntax bellow ${{}} is expression syntax in github actions
# Success and failure are status expressions
if: ${{ success() }} # Only run this step if the previous step succeeded
run: |
echo "Running because the previous step has succeeded"
- name: Step 3 - I am Failing
run: |
echo "I am failing"
exit 1 # Failure (non-zero exit code)
- name: Step 4 - I Will Never Execute # Because of failure of Step 3
run: |
echo "I will never execute"
- name: Step 5 - Execute on Workflow Failure
if: ${{ failure() }} # Only run this step if the workflow failed
run: |
echo "Workflow failed"
+26
View File
@@ -0,0 +1,26 @@
name: Parallel Jobs
on:
workflow_dispatch:
jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: Linting
run: echo "Running linting..."
unit_tests:
runs-on: ubuntu-latest
steps:
- name: Unit Tests
run: echo "Running unit tests..."
integration_tests:
runs-on: ubuntu-latest
steps:
- name: Set Up Test Environment
run: echo "Setting up test environment..."
- name: Integration Tests
run: echo "Running integration tests..."
+23
View File
@@ -0,0 +1,23 @@
name: workflow_dispatch # Name of workflow
on:
workflow_dispatch:
inputs:
username:
description: 'Username'
default: 'Hang'
required: true
type: string
age:
description: 'Age'
required: true
type: number
jobs:
echo-username-age: # Name of job
runs-on: ubuntu-latest
steps:
- name: Echo Username and Age
run: |
echo "Username: ${{ inputs.username }}"
echo "Age: ${{ inputs.age }}"
+17
View File
@@ -0,0 +1,17 @@
name: workflow_run # Name of workflow
on:
workflow_run: # Depend on the workflow completion of "workflow_dispatch"
workflows: ["workflow_dispatch"]
types:
- completed
jobs:
echo-hi-all: # Name of job
# Only run if the first workflow succeeded
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Echo "Hi all"
run: |
echo "Hi all (chained via workflow_run)"
@@ -0,0 +1,19 @@
name: Checkout Example
on:
workflow_dispatch:
jobs:
demo-checkout:
runs-on: ubuntu-latest
steps:
- name: List space
# workspace is a special variable containing the path to the working directory
# on the runner machine. Github is a context which we can access in expression ${{}}.
run: ls -la ${{ github.workspace }}
- name: Checkout source code
uses: actions/checkout@v4 # use github action from repo github.com/actions/checkout
- name: List space again
run: ls -la ${{ github.workspace }}
@@ -0,0 +1,24 @@
name: Passing Data Between Jobs
on:
workflow_dispatch:
jobs:
data-sender:
runs-on: ubuntu-22.04
steps:
- name: Create data
id: sender # Set the output name for this step to Apple
run: |
echo "name=Apple" >> $GITHUB_OUTPUT
outputs:
name: ${{ steps.sender.outputs.name }}
data-receiver:
runs-on: ubuntu-22.04
needs: ["data-sender"]
steps: # In order to have data for receiver sender needs to first produce some data.
- name: Receive data
# Notice how we use needs object to access the sender job's outputs
run: |
echo ${{ needs.data-sender.outputs.name }}
@@ -0,0 +1,17 @@
name: Passing Data Between Steps
on:
workflow_dispatch:
jobs:
data-passing:
runs-on: ubuntu-22.04
steps:
- name: Create data
id: sender # Set the output name for this step to Apple
run: |
echo "name=Apple" >> $GITHUB_OUTPUT
- name: Receive data
run: |
echo ${{ steps.sender.outputs.name }}
+26
View File
@@ -0,0 +1,26 @@
name: Upload Artifacts
on:
workflow_dispatch:
jobs:
build-and-upload:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Create an artifact
run: |
ls -la ${{ github.workspace }}
cd backend
echo "This is my artifact content." > artifact.txt
ls -la ${{ github.workspace }}/backend
stat ./artifact.txt
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-artifact # Folder name of artifact.txt
path: ${{ github.workspace }}/backend/artifact.txt
retention-days: 5 # Optional: Set the retention period for the artifact
@@ -0,0 +1,51 @@
name: Passing Files In Artifacts
on:
workflow_dispatch:
jobs:
unit-tests:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Python 3.10.12 # Setup Python inside the runner
uses: actions/setup-python@v4
with:
python-version: '3.10.12'
- name: Install tox # Tool used for Python unit tests
run: pip install tox
- name: Run unit tests
run: | # Use zip to take care of .hidden_files
cd backend
apt install zip
COVERAGE_FILE=.coverage tox -e unit
ls -la ${{ github.workspace }}/backend
stat ./.coverage
zip coverage.zip ./.coverage
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: build-coverage
path: ${{ github.workspace }}/backend/coverage.zip
if-no-files-found: error
load-file-example:
runs-on: ubuntu-22.04
needs: [unit-tests]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: build-coverage
path: ${{ github.workspace }} # Move the coverage to ${{ github.workspace }}
- name: List folder
run: |
ls -la ${{ github.workspace }}
unzip coverage.zip
ls -la ${{ github.workspace }}
@@ -0,0 +1,38 @@
name: Secrets And Variables
on:
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-22.04
env:
DEPLOYMENT_ENV: 'production' # Define a workflow-level environment variable
steps:
- name: Build
run: | # Build your application here
echo "Building the application"
echo "API_KEY: ${{ secrets.API_KEY }}"
echo $SECRET_API_KEY
echo "DEPLOYMENT_ENV: ${{ env.DEPLOYMENT_ENV }}"
echo $CONFIG_VARIABLE
echo "USERNAME: ${{ vars.USERNAME }}"
echo $STEPS_USERNAME
env:
SECRET_API_KEY: ${{ secrets.API_KEY }} # Access a secret as an environment variable
STEPS_USERNAME: ${{ vars.USERNAME }}
CONFIG_VARIABLE: ${{ env.DEPLOYMENT_ENV }} # Use a workflow-level environment variable
- name: Deploy
run: | # Deploy your application using the secrets and variables
echo "Global job variable ${{ env.DEPLOYMENT_ENV }}"
echo "Variable from this step ${CONFIG_VARIABLE2} environment"
echo "Local step variable ${ANOTHER_VARIABLE}"
echo "Secret print ${{ secrets.API_KEY }}"
echo "Step's secret variable ${SECRET_API_KEY}"
env:
SECRET_API_KEY: ${{ secrets.API_KEY }}
CONFIG_VARIABLE2: ${{ env.DEPLOYMENT_ENV }} # Use a workflow-level environment variable
ANOTHER_VARIABLE: 'some value' # Define a variable directly in the workflow
+29
View File
@@ -0,0 +1,29 @@
name: Matrix
on:
workflow_dispatch:
jobs:
run-tests:
strategy:
fail-fast: true
matrix:
os: [ubuntu-20.04, ubuntu-22.04]
python-version: ['3.8', '3.10']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: Install tox
run: pip install tox
- name: Run unit tests
run: |
cd backend
tox -e unit
+150
View File
@@ -0,0 +1,150 @@
name: Example CI
on:
workflow_dispatch:
inputs:
image-name:
description: "Name for image"
default: "gitea.cuihang1201.synology.me/hangpersonal/ci-test"
type: string
required: true
image-tag:
description: "Tag for image"
default: "latest"
type: string
required: true
container-name:
description: "Name for container"
default: "ci-test"
type: string
required: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install tox
run: pip install tox
- name: Run lint
run: |
cd backend
tox -e lint
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install tox
run: pip install tox
- name: Run unit tests
run: |
cd backend
tox -e unit
build-image:
runs-on: ubuntu-latest
needs: [lint, unit-test] # Specify that build-image depends on lint and unit-test
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and export
uses: docker/build-push-action@v5 # Build Docker image via Dockerfile
with:
context: backend # Directory of Dockerfile
tags: ${{ inputs.image-name }}:${{ inputs.image-tag }}
outputs: type=docker,dest=/tmp/image.tar
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: image
path: /tmp/image.tar
retention-days: 1
integration-tests:
runs-on: ubuntu-latest
needs: [build-image]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image
path: /tmp
- name: Load image
run: |
docker load --input /tmp/image.tar
docker image ls -a
docker run --rm -p 8143:80 --name ${{ inputs.container-name }} -d ${{ inputs.image-name }}:${{ inputs.image-tag }}
sleep 5
curl -s "http://${{ vars.LOCALHOST }}:8143/" ; echo
echo "Stop container: "
docker container stop ${{ inputs.container-name }}
vulnerability-scan:
runs-on: ubuntu-latest
needs: [build-image]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image
path: /tmp
- name: Install Trivy CLI
run: |
set -euo pipefail
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh \
| sh -s -- -b /usr/local/bin v0.65.0
trivy --version
- name: Scan saved image tar with Trivy
run: |
ls -la /tmp || true
trivy image \
--input /tmp/image.tar \
--format json \
--output /tmp/trivy-results.json \
--severity CRITICAL,HIGH \
--ignore-unfixed
- name: Upload results
uses: actions/upload-artifact@v3
with:
name: trivy-results
path: /tmp/trivy-results.json
retention-days: 1
publish-image:
runs-on: ubuntu-latest
needs: [integration-tests, vulnerability-scan]
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image
path: /tmp
- name: Load image
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Login to Gitea Docker Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | \
docker login gitea.cuihang1201.synology.me -u ${{ secrets.REGISTRY_USER }} --password-stdin
- name: Push Docker image
run: |
docker image ls -a
docker push ${{ inputs.image-name }}:${{ inputs.image-tag }}
- name: Clean Docker image on Host
run: |
docker rmi ${{ inputs.image-name }}:${{ inputs.image-tag }}
docker image ls -a
+23
View File
@@ -0,0 +1,23 @@
name: "Permissions"
on:
workflow_dispatch:
jobs:
example-job:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Attempt Write Operation
run: |
touch permissions-test.txt
git config --global user.name 'hangpersonal'
git config --global user.email 'hangcui1201@gmail.com'
git add permissions-test.txt
git commit -m "Attempt to write"
git push origin ${{ github.ref }}
@@ -0,0 +1,29 @@
name: "Permissions Error"
on:
workflow_dispatch:
permissions:
contents: read # only read commits/tags cannot create ones from this workflow
jobs:
example-job:
# It can be also here for job scope
# permissions:
# contents: read
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Attempt Write Operation
run: |
# This is an intentional error to demonstrate lack of write permissions
touch new-file.txt
git config --global user.name 'hangpersonal'
git config --global user.email 'hangcui1201@gmail.com'
git add new-file.txt
git commit -m "Attempt to write"
git push origin ${{ github.ref }}
continue-on-error: true
+31
View File
@@ -0,0 +1,31 @@
name: Pat Bump Tag
on:
pull_request:
types:
- closed
branches:
- main
jobs:
build:
# Accessing the context for Github
if: ${{ github.event.pull_request.merged == true }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: '0'
- name: Bump version and push tag
id: tag
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.REGISTRY_TOKEN }}
release_branches: main
default_bump: minor # major, minor, or patch
tag_prefix: v
- name: Show new tag
run: echo "New tag is ${{ steps.tag.outputs.new_tag }}"
+26 -23
View File
@@ -1,24 +1,27 @@
name: CI Workflow
on:
push:
branches:
- "**"
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
name: CI Workflow
#on:
# push:
# branches:
# - "**"
on:
workflow_dispatch:
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: pytest -v
+55 -25
View File
@@ -1,25 +1,55 @@
name: Docker Build
on:
push:
branches:
- main
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Gitea Registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login gitea.cuihang1201.synology.me -u hangpersonal --password-stdin
- name: Build Docker image
run: docker build -t gitea.cuihang1201.synology.me/hangpersonal/myapp:latest .
- name: Run Docker image
run: docker run --rm gitea.cuihang1201.synology.me/hangpersonal/myapp:latest
- name: Push Docker image
run: docker push gitea.cuihang1201.synology.me/hangpersonal/myapp:latest
name: Docker Build
"on":
workflow_dispatch:
# Uncomment if you also want auto-builds on pushes:
# push:
# branches: [ "main" ]
jobs:
docker:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Registry
uses: docker/login-action@v3
with:
registry: gitea.cuihang1201.synology.me
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: gitea.cuihang1201.synology.me/hangpersonal/docker-build:latest
# Optional quick health check, runs detached and then cleaned up
- name: Smoke test
run: |
docker run --name docker-build \
gitea.cuihang1201.synology.me/hangpersonal/docker-build:latest
sleep 5
if: ${{ always() }}
- name: Cleanup local container/images
if: always()
run: |
echo "Stop container: "
docker stop docker-build
echo "Remove container: "
docker rm -f docker-build 2>/dev/null || true
echo "Remove image: "
docker rmi gitea.cuihang1201.synology.me/hangpersonal/docker-build:latest
docker image ls -a
+44 -42
View File
@@ -1,42 +1,44 @@
name: Release Workflow
on:
# The workflow only runs with push a Git tag
push:
tags:
- "v*.*.*" # v1.0.0, v2.5.3, v10.23.7
jobs:
# Defines a job named release
release:
# According to the Gitea documentation, the ubuntu-latest label is mapped
# internally to Ubuntu 22.04 environments
runs-on: ubuntu-latest
steps:
- name: Checkout code
# Pulls your repo into the runner so it has access to the source code
uses: actions/checkout@v3
- name: Build artifact
# Makes a directory dist/
# Creates a file README.txt inside dist/
# $GITHUB_REF_NAME is an environment variable set by Actions -
# it will be the name of the Git tag that triggered this workflow
# If you pushed v1.2.3, the file will contain "Release version v1.2.3"
# run, execute these shell commands
# |, treat everything indented below this as a multi-line string,
# and keep line breaks as they are.
# /workspace/<owner>/<repo>/dist/
run: |
mkdir dist
echo "Release version $GITHUB_REF_NAME" > dist/README.txt
echo "Ref $GITHUB_REF" >> dist/README.txt
- name: Upload artifact
# Packages whatever is inside dist/ (in this case, just the README.txt)
# Uploads it to Gitea Actions as a downloadable artifact
# In the Actions UI, after the run finishes, a link to download release-files.zip
uses: actions/upload-artifact@v3
with:
name: release-files
path: dist/
name: Release Workflow
on:
workflow_dispatch:
#on: # The workflow only runs with push a Git tag
# push:
# tags:
# - "v*.*.*" # v1.0.0, v2.5.3, v10.23.7
jobs:
# Defines a job named release
release:
# According to the Gitea documentation, the ubuntu-latest label is mapped
# internally to Ubuntu 22.04 environments
runs-on: ubuntu-22.04
steps:
- name: Checkout code
# Pulls your repo into the runner so it has access to the source code
uses: actions/checkout@v4
- name: Build artifact
# Makes a directory dist/
# Creates a file README.txt inside dist/
# $GITHUB_REF_NAME is an environment variable set by Actions -
# it will be the name of the Git tag that triggered this workflow
# If you pushed v1.2.3, the file will contain "Release version v1.2.3"
# run, execute these shell commands
# |, treat everything indented below this as a multi-line string,
# and keep line breaks as they are.
# /workspace/<owner>/<repo>/dist/
run: |
mkdir dist
echo "Release version $GITHUB_REF_NAME" > dist/README.txt
echo "Ref $GITHUB_REF" >> dist/README.txt
- name: Upload artifact
# Packages whatever is inside dist/ (in this case, just the README.txt)
# Uploads it to Gitea Actions as a downloadable artifact
# In the Actions UI, after the run finishes, a link to download release-files.zip
uses: actions/upload-artifact@v3
with:
name: release-files
path: dist/
+9
View File
@@ -0,0 +1,9 @@
venv/
build/
*.charm
.tox/
.coverage
__pycache__/
.pytest_cache/
*.py[cod]
.idea
+15 -15
View File
@@ -1,15 +1,15 @@
# Base image with Python 3.10
FROM python:3.10-slim
# Set work directory inside container
WORKDIR /app
# Copy dependency file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your code
COPY . .
# Default command (can be overridden in docker run)
CMD ["python3", "main.py"]
# Base image with Python 3.10
FROM python:3.10-slim
# Set work directory inside container
WORKDIR /app
# Copy dependency file and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your code
COPY . .
# Default command (can be overridden in docker run)
CMD ["python3", "main.py"]
+18 -18
View File
@@ -1,18 +1,18 @@
MIT License
Copyright (c) 2025 hangpersonal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License
Copyright (c) 2025 hangpersonal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
+1
View File
@@ -1,2 +1,3 @@
# Gitea_Action_Test
Test pull request with 012_pat.yaml and pull_request_test branch
+9
View File
@@ -0,0 +1,9 @@
FROM python:3.10-slim
WORKDIR /app
COPY requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
EXPOSE 80
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80"]
+8
View File
@@ -0,0 +1,8 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, World!"}
+24
View File
@@ -0,0 +1,24 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile requirements-fmt.in
#
black==23.9.1
# via -r requirements-fmt.in
click==8.1.7
# via black
isort==5.12.0
# via -r requirements-fmt.in
mypy-extensions==1.0.0
# via black
packaging==23.1
# via black
pathspec==0.11.2
# via black
platformdirs==3.10.0
# via black
tomli==2.0.1
# via black
typing-extensions==4.8.0
# via black
+51
View File
@@ -0,0 +1,51 @@
#
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile requirements-lint.in
#
black==23.9.1
# via -r requirements-lint.in
click==8.1.7
# via black
codespell==2.2.5
# via -r requirements-lint.in
flake8==6.0.0
# via
# -r requirements-lint.in
# flake8-builtins
# pep8-naming
# pyproject-flake8
flake8-builtins==2.1.0
# via -r requirements-lint.in
flake8-copyright==0.2.4
# via -r requirements-lint.in
isort==5.12.0
# via -r requirements-lint.in
mccabe==0.7.0
# via flake8
mypy-extensions==1.0.0
# via black
packaging==23.1
# via black
pathspec==0.11.2
# via black
pep8-naming==0.13.3
# via -r requirements-lint.in
platformdirs==3.10.0
# via black
pycodestyle==2.10.0
# via flake8
pyflakes==3.0.1
# via flake8
pyproject-flake8==6.0.0.post1
# via -r requirements-lint.in
tomli==2.0.1
# via
# black
# pyproject-flake8
typing-extensions==4.8.0
# via black
# The following packages are considered to be unsafe in a requirements file:
# setuptools
+5
View File
@@ -0,0 +1,5 @@
coverage
fastapi
httpx
pytest
uvicorn
+4
View File
@@ -0,0 +1,4 @@
fastapi
httpx
pytest
uvicorn
View File
+11
View File
@@ -0,0 +1,11 @@
from fastapi.testclient import TestClient
from main import app
client = TestClient(app)
def test_read_root():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"message": "Hello, World!"}
+54
View File
@@ -0,0 +1,54 @@
[flake8]
max-line-length = 100
[tox]
skipsdist = True
skip_missing_interpreters = True
envlist = fmt, lint, unit, integration
[vars]
all_path = {[vars]src_path} {[vars]tst_path}
src_path = {toxinidir}
tst_path = {toxinidir}/tests/
[testenv]
passenv =
PYTHONPATH
CHARM_BUILD_DIR
MODEL_SETTINGS
KUBECONFIG
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/lib:{[vars]src_path}
PYTHONBREAKPOINT=ipdb.set_trace
PY_COLORS=1
[testenv:fmt]
commands =
isort {[vars]all_path}
black {[vars]all_path}
deps =
-r requirements-fmt.txt
description = Apply coding style standards to code
[testenv:lint]
commands =
codespell {toxinidir}/. --skip {toxinidir}/.git --skip {toxinidir}/.tox \
--skip {toxinidir}/build --skip {toxinidir}/lib --skip {toxinidir}/venv \
--skip {toxinidir}/.mypy_cache \
--skip {toxinidir}/icon.svg --skip *.json.tmpl
# pflake8 wrapper supports config from pyproject.toml
pflake8 {[vars]all_path}
isort --check-only --diff {[vars]all_path}
black --check --diff {[vars]all_path}
deps =
-r requirements-lint.txt
description = Check code against coding style standards
[testenv:unit]
commands =
coverage run --source={[vars]src_path} \
-m pytest -vv --tb native {posargs}
coverage report
deps =
-r requirements-unit.txt
description = Run unit tests
View File
View File
+4 -4
View File
@@ -1,4 +1,4 @@
[pytest]
testpaths = tests
python_files = test_*.py
python_functions = test_*
[pytest]
testpaths = tests
python_files = test_*.py
python_functions = test_*
+2 -2
View File
@@ -1,3 +1,3 @@
numpy==1.26.4
requests>=2.31
numpy==1.26.4
requests>=2.31
pytest
+2 -2
View File
@@ -1,3 +1,3 @@
# tests/test_smoke.py
def test_smoke():
# tests/test_smoke.py
def test_smoke():
assert True