Compare commits

..

94 Commits

Author SHA1 Message Date
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
696bd8993b Pull request demo
Some checks failed
Pat Bump Tag / build (pull_request) Failing after 28s
2025-10-19 12:50:27 -07:00
a50c2a58c6 Add .gitea/workflows/*.yaml 2025-10-19 12:49:03 -07:00
6a30911696 Attempt to write 2025-10-19 18:31:47 +00:00
1082bce072 Attempt to write 2025-10-19 18:28:59 +00:00
0b8b71bdfc Add .gitea/workflows/*.yaml 2025-10-19 11:28:13 -07:00
f2591496ab Add .gitea/workflows/*.yaml 2025-10-19 10:03:24 -07:00
2843d7c765 Add .gitea/workflows/*.yaml 2025-10-19 09:31:26 -07:00
f22df7b6bf Add .gitea/workflows/*.yaml 2025-10-19 09:07:57 -07:00
9aed5a1f23 Add .gitea/workflows/*.yaml 2025-10-19 00:38:30 -07:00
3269f2f461 Add .gitea/workflows/*.yaml 2025-10-18 23:54:27 -07:00
7f7020f53c Add .gitea/workflows/*.yaml 2025-10-18 23:45:52 -07:00
727cee9e54 Add .gitea/workflows/*.yaml 2025-10-18 23:29:49 -07:00
4608d136e6 Add .gitea/workflows/*.yaml 2025-10-18 23:23:20 -07:00
c78a43048e Add .gitea/workflows/*.yaml 2025-10-18 23:02:39 -07:00
e6afe787a6 Add .gitea/workflows/*.yaml 2025-10-18 22:44:01 -07:00
51709470b9 Add .gitea/workflows/*.yaml 2025-10-18 22:39:59 -07:00
f2769fa2f4 Add .gitea/workflows/*.yaml 2025-10-18 22:31:44 -07:00
7197043d8a Add .gitea/workflows/*.yaml 2025-10-18 22:11:15 -07:00
c867e96806 Add .gitea/workflows/*.yaml 2025-10-18 21:14:17 -07:00
c4bd57ba93 Add .gitea/workflows/*.yaml 2025-10-18 20:57:21 -07:00
0ac7387f38 Add .gitea/workflows/*.yaml 2025-10-18 20:32:35 -07:00
17c32c00d3 Add .gitea/workflows/*.yaml 2025-10-18 20:13:26 -07:00
a20407ef42 Add .gitea/workflows/*.yaml 2025-10-18 17:05:28 -07:00
bf8736f9a5 Add .gitea/workflows/*.yaml 2025-10-18 16:51:32 -07:00
cc176da1ed Add .gitea/workflows/*.yaml 2025-10-18 16:42:03 -07:00
391cd397f0 Add .gitea/workflows/*.yaml 2025-10-18 16:32:39 -07:00
7e858447b6 Add .gitea/workflows/*.yaml 2025-10-18 16:24:05 -07:00
87369f5924 Add .gitea/workflows/*.yaml 2025-10-18 16:16:57 -07:00
1cebfa83c3 Add .gitea/workflows/*.yaml 2025-10-18 15:29:30 -07:00
091411890b Add .gitea/workflows/*.yaml 2025-10-18 15:10:44 -07:00
ffe70f38aa Add .gitea/workflows/*.yaml 2025-10-18 15:01:14 -07:00
3abaedccf5 Add .gitea/workflows/*.yaml 2025-10-18 14:35:09 -07:00
eb777c2486 Add .gitea/workflows/*.yaml 2025-10-18 12:56:22 -07:00
13ab374302 Add .gitea/workflows/*.yaml 2025-10-18 12:49:36 -07:00
8d81f41a9f Add .gitea/workflows/*.yaml 2025-10-18 12:33:40 -07:00
d635a0ceed Add .gitea/workflows/*.yaml 2025-10-18 12:24:19 -07:00
9f45610da4 Add .gitea/workflows/*.yaml 2025-10-18 02:01:56 -07:00
676c2b0624 Add .gitea/workflows/*.yaml 2025-10-18 01:36:56 -07:00
7c19e34337 Add .gitea/workflows/*.yaml 2025-10-18 01:30:43 -07:00
89d2950754 Add .gitea/workflows/*.yaml 2025-10-18 01:20:16 -07:00
29a8ab5115 Add .gitea/workflows/*.yaml 2025-10-18 01:06:37 -07:00
b65f488cf2 Add .gitea/workflows/*.yaml 2025-10-18 00:37:07 -07:00
c5a76614f4 Add .gitea/workflows/*.yaml 2025-10-18 00:35:31 -07:00
0638a82a8d Add .gitea/workflows/*.yaml 2025-10-18 00:12:42 -07:00
2719d95738 Add .gitea/workflows/*.yaml 2025-10-18 00:10:26 -07:00
19bcb361c0 Add .gitea/workflows/*.yaml 2025-10-17 21:04:58 -07:00
c57f058e99 Add .gitea/workflows/*.yaml 2025-10-17 21:02:57 -07:00
3f964846f8 Add .gitea/workflows/*.yaml 2025-10-17 21:00:30 -07:00
dce2c5af71 Add .gitea/workflows/*.yaml 2025-10-17 20:56:19 -07:00
b4e01e369e Add .gitea/workflows/*.yaml 2025-10-17 20:54:03 -07:00
e7dc599785 Add .gitea/workflows/*.yaml 2025-10-17 20:48:56 -07:00
184e12e0b8 Add .gitea/workflows/*.yaml 2025-10-17 20:45:53 -07:00
61bc3904b3 Add .gitea/workflows/*.yaml 2025-10-17 20:43:19 -07:00
8cc758ad73 Add .gitea/workflows/*.yaml 2025-10-17 20:37:44 -07:00
295c346094 Add .gitea/workflows/*.yaml 2025-10-17 20:09:34 -07:00
5e5f21993e Add .gitea/workflows/*.yaml 2025-10-17 20:04:45 -07:00
01ae91e8d5 Add .gitea/workflows/*.yaml 2025-10-17 20:02:46 -07:00
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
All checks were successful
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
7eb71757ea Update *.yaml 2025-10-16 23:58:47 -07:00
7101ddb38c Update *.yaml 2025-10-16 23:04:31 -07:00
2c24d17eb1 Update manual_trigger.yaml
All checks were successful
CI Workflow / build-and-test (push) Successful in 1m13s
Docker Build / docker (push) Successful in 16s
2025-10-16 22:57:28 -07:00
e0002a1d99 Add manual_trigger.yaml
All checks were successful
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 879 additions and 133 deletions

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"

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..."

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 }}"

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)"

View File

@@ -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 }}

View File

@@ -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 }}

View File

@@ -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 }}

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

View File

@@ -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 }}

View File

@@ -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

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

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

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 }}

View File

@@ -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

View File

@@ -0,0 +1,26 @@
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
uses: anothrNick/github-tag-action@1.64.0
env:
# if you don't want to set write permissions use a PAT token
GITHUB_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
WITH_V: true

View File

@@ -1,24 +1,27 @@
name: CI Workflow name: CI Workflow
on: #on:
push: # push:
branches: # branches:
- "**" # - "**"
jobs: on:
build-and-test: workflow_dispatch:
runs-on: ubuntu-latest
steps: jobs:
- name: Checkout code build-and-test:
uses: actions/checkout@v3 runs-on: ubuntu-latest
steps:
- name: Set up Python - name: Checkout code
uses: actions/setup-python@v4 uses: actions/checkout@v4
with:
python-version: "3.10" - name: Set up Python
uses: actions/setup-python@v4
- name: Install dependencies with:
run: pip install -r requirements.txt python-version: "3.10"
- name: Run tests - name: Install dependencies
run: pip install -r requirements.txt
- name: Run tests
run: pytest -v run: pytest -v

View File

@@ -1,25 +1,55 @@
name: Docker Build name: Docker Build
on: "on":
push: workflow_dispatch:
branches: # Uncomment if you also want auto-builds on pushes:
- main # push:
# branches: [ "main" ]
jobs:
docker: jobs:
runs-on: ubuntu-latest docker:
steps: runs-on: ubuntu-latest
- name: Checkout code permissions:
uses: actions/checkout@v3 contents: read
packages: write
- name: Log in to Gitea Registry
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login gitea.cuihang1201.synology.me -u hangpersonal --password-stdin steps:
- name: Checkout code
- name: Build Docker image uses: actions/checkout@v4
run: docker build -t gitea.cuihang1201.synology.me/hangpersonal/myapp:latest .
- name: Set up Docker Buildx
- name: Run Docker image uses: docker/setup-buildx-action@v3
run: docker run --rm gitea.cuihang1201.synology.me/hangpersonal/myapp:latest
- name: Log in to Gitea Registry
- name: Push Docker image uses: docker/login-action@v3
run: docker push gitea.cuihang1201.synology.me/hangpersonal/myapp:latest 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

View File

@@ -1,42 +1,44 @@
name: Release Workflow name: Release Workflow
on: on:
# The workflow only runs with push a Git tag workflow_dispatch:
push:
tags: #on: # The workflow only runs with push a Git tag
- "v*.*.*" # v1.0.0, v2.5.3, v10.23.7 # push:
# tags:
jobs: # - "v*.*.*" # v1.0.0, v2.5.3, v10.23.7
# Defines a job named release
release: jobs:
# According to the Gitea documentation, the ubuntu-latest label is mapped # Defines a job named release
# internally to Ubuntu 22.04 environments release:
runs-on: ubuntu-latest # According to the Gitea documentation, the ubuntu-latest label is mapped
steps: # internally to Ubuntu 22.04 environments
- name: Checkout code runs-on: ubuntu-22.04
# Pulls your repo into the runner so it has access to the source code steps:
uses: actions/checkout@v3 - name: Checkout code
# Pulls your repo into the runner so it has access to the source code
- name: Build artifact uses: actions/checkout@v4
# Makes a directory dist/
# Creates a file README.txt inside dist/ - name: Build artifact
# $GITHUB_REF_NAME is an environment variable set by Actions - # Makes a directory dist/
# it will be the name of the Git tag that triggered this workflow # Creates a file README.txt inside dist/
# If you pushed v1.2.3, the file will contain "Release version v1.2.3" # $GITHUB_REF_NAME is an environment variable set by Actions -
# run, execute these shell commands # it will be the name of the Git tag that triggered this workflow
# |, treat everything indented below this as a multi-line string, # If you pushed v1.2.3, the file will contain "Release version v1.2.3"
# and keep line breaks as they are. # run, execute these shell commands
# /workspace/<owner>/<repo>/dist/ # |, treat everything indented below this as a multi-line string,
run: | # and keep line breaks as they are.
mkdir dist # /workspace/<owner>/<repo>/dist/
echo "Release version $GITHUB_REF_NAME" > dist/README.txt run: |
echo "Ref $GITHUB_REF" >> dist/README.txt mkdir dist
echo "Release version $GITHUB_REF_NAME" > dist/README.txt
- name: Upload artifact echo "Ref $GITHUB_REF" >> dist/README.txt
# Packages whatever is inside dist/ (in this case, just the README.txt)
# Uploads it to Gitea Actions as a downloadable artifact - name: Upload artifact
# In the Actions UI, after the run finishes, a link to download release-files.zip # Packages whatever is inside dist/ (in this case, just the README.txt)
uses: actions/upload-artifact@v3 # Uploads it to Gitea Actions as a downloadable artifact
with: # In the Actions UI, after the run finishes, a link to download release-files.zip
name: release-files uses: actions/upload-artifact@v3
path: dist/ with:
name: release-files
path: dist/

9
.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
venv/
build/
*.charm
.tox/
.coverage
__pycache__/
.pytest_cache/
*.py[cod]
.idea

View File

@@ -1,15 +1,15 @@
# Base image with Python 3.10 # Base image with Python 3.10
FROM python:3.10-slim FROM python:3.10-slim
# Set work directory inside container # Set work directory inside container
WORKDIR /app WORKDIR /app
# Copy dependency file and install dependencies # Copy dependency file and install dependencies
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
# Copy the rest of your code # Copy the rest of your code
COPY . . COPY . .
# Default command (can be overridden in docker run) # Default command (can be overridden in docker run)
CMD ["python3", "main.py"] CMD ["python3", "main.py"]

36
LICENSE
View File

@@ -1,18 +1,18 @@
MIT License MIT License
Copyright (c) 2025 hangpersonal Copyright (c) 2025 hangpersonal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 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 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 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 copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions: following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software. portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 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 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 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 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. USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,2 +1,3 @@
# Gitea_Action_Test # Gitea_Action_Test
Test pull request with 012_pat.yaml

9
backend/Dockerfile Normal file
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
backend/main.py Normal file
View File

@@ -0,0 +1,8 @@
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def read_root():
return {"message": "Hello, World!"}

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

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

View File

@@ -0,0 +1,5 @@
coverage
fastapi
httpx
pytest
uvicorn

4
backend/requirements.txt Normal file
View File

@@ -0,0 +1,4 @@
fastapi
httpx
pytest
uvicorn

View File

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
backend/tox.ini Normal file
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

0
new-file.txt Normal file
View File

0
permissions-test.txt Normal file
View File

View File

@@ -1,4 +1,4 @@
[pytest] [pytest]
testpaths = tests testpaths = tests
python_files = test_*.py python_files = test_*.py
python_functions = test_* python_functions = test_*

View File

@@ -1,3 +1,3 @@
numpy==1.26.4 numpy==1.26.4
requests>=2.31 requests>=2.31
pytest pytest

View File

@@ -1,3 +1,3 @@
# tests/test_smoke.py # tests/test_smoke.py
def test_smoke(): def test_smoke():
assert True assert True