diff --git a/.gitea/workflows/001_manual_trigger.yaml b/.gitea/workflows/001_manual_trigger.yaml index 0bad95b..1a4bcca 100644 --- a/.gitea/workflows/001_manual_trigger.yaml +++ b/.gitea/workflows/001_manual_trigger.yaml @@ -1,37 +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: | +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" \ No newline at end of file diff --git a/.gitea/workflows/002_parallel_jobs.yaml b/.gitea/workflows/002_parallel_jobs.yaml index c80c35c..1c6866f 100644 --- a/.gitea/workflows/002_parallel_jobs.yaml +++ b/.gitea/workflows/002_parallel_jobs.yaml @@ -1,26 +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 +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..." \ No newline at end of file diff --git a/.gitea/workflows/003_first_workflow.yaml b/.gitea/workflows/003_first_workflow.yaml new file mode 100644 index 0000000..8bb7819 --- /dev/null +++ b/.gitea/workflows/003_first_workflow.yaml @@ -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 }}" diff --git a/.gitea/workflows/003_second_workflow.yaml b/.gitea/workflows/003_second_workflow.yaml new file mode 100644 index 0000000..03285ce --- /dev/null +++ b/.gitea/workflows/003_second_workflow.yaml @@ -0,0 +1,15 @@ +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 + runs-on: ubuntu-latest + steps: + - name: Echo "Hi all" + run: | + echo "Hi all" diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index b0850ed..d796d38 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,27 +1,27 @@ -name: CI Workflow - -#on: -# push: -# branches: -# - "**" - -on: - workflow_dispatch: - -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@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 run: pytest -v \ No newline at end of file diff --git a/.gitea/workflows/docker-build.yml b/.gitea/workflows/docker-build.yml index b442be2..9f0303f 100644 --- a/.gitea/workflows/docker-build.yml +++ b/.gitea/workflows/docker-build.yml @@ -1,28 +1,28 @@ -name: Docker Build - -on: - workflow_dispatch: - -#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: + +#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 diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index 049e767..1fc2647 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,44 +1,44 @@ -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-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///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-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///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/ diff --git a/Dockerfile b/Dockerfile index 382f270..969f98e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/LICENSE b/LICENSE index 9886108..dd4aadb 100644 --- a/LICENSE +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md index 6265f5c..5bc45cd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Gitea_Action_Test - +# Gitea_Action_Test + diff --git a/pytest.ini b/pytest.ini index 6605410..c353ecb 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,4 @@ -[pytest] -testpaths = tests -python_files = test_*.py -python_functions = test_* +[pytest] +testpaths = tests +python_files = test_*.py +python_functions = test_* diff --git a/requirements.txt b/requirements.txt index 4002e7b..575eceb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -numpy==1.26.4 -requests>=2.31 +numpy==1.26.4 +requests>=2.31 pytest \ No newline at end of file diff --git a/tests/test_smoke.py b/tests/test_smoke.py index cea8453..1286d8e 100644 --- a/tests/test_smoke.py +++ b/tests/test_smoke.py @@ -1,3 +1,3 @@ -# tests/test_smoke.py -def test_smoke(): +# tests/test_smoke.py +def test_smoke(): assert True \ No newline at end of file