Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed8684a289 | ||
|
|
35605c33b9 | ||
|
|
b0eee02470 | ||
|
|
ff266cf33c |
@@ -0,0 +1,2 @@
|
|||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
Vendored
+27
@@ -0,0 +1,27 @@
|
|||||||
|
pipeline {
|
||||||
|
agent { label 'controller-small-trusted' }
|
||||||
|
options {
|
||||||
|
skipDefaultCheckout()
|
||||||
|
disableConcurrentBuilds()
|
||||||
|
timeout(time: 5, unit: 'MINUTES')
|
||||||
|
buildDiscarder(logRotator(numToKeepStr: '20'))
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Checkout') {
|
||||||
|
steps {
|
||||||
|
checkout scm
|
||||||
|
sh 'git rev-parse HEAD && python3 --version'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Syntax check') {
|
||||||
|
steps {
|
||||||
|
sh 'python3 -m py_compile pricing.py tests/test_pricing.py'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Unit tests') {
|
||||||
|
steps {
|
||||||
|
sh 'python3 -m unittest discover -s tests -v'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,7 @@ This repository supports the Chapter 2 Gitea foundation assignment. It is used t
|
|||||||
|
|
||||||
- Gitea is running from a pinned official container image.
|
- Gitea is running from a pinned official container image.
|
||||||
- SQLite data and repositories are stored in persistent host-mounted storage.
|
- SQLite data and repositories are stored in persistent host-mounted storage.
|
||||||
- The current HTTP URL is temporary until DNS and HTTPS are configured.
|
- Gitea uses https://git.sespinal590.dev/ through the Caddy TLS proxy.
|
||||||
|
|
||||||
## Product Vision
|
## Product Vision
|
||||||
|
|
||||||
@@ -19,3 +19,21 @@ Target users are SSW 590 team members who need a shared place to plan, review, a
|
|||||||
1. Issue tracking workflow: maintain product and operations issues with clear acceptance criteria.
|
1. Issue tracking workflow: maintain product and operations issues with clear acceptance criteria.
|
||||||
2. Pull request review workflow: require changes to be proposed on branches and reviewed before merge.
|
2. Pull request review workflow: require changes to be proposed on branches and reviewed before merge.
|
||||||
3. Operations evidence workflow: record restart, persistence, DNS, HTTPS, and firewall verification evidence in the IT manual.
|
3. Operations evidence workflow: record restart, persistence, DNS, HTTPS, and firewall verification evidence in the IT manual.
|
||||||
|
|
||||||
|
|
||||||
|
## Chapter 4 tested application
|
||||||
|
|
||||||
|
This repository uses the assignment manual's permitted minimal Python pricing application. `total_price` multiplies a unit price by a positive quantity and rejects zero/negative quantities. It is a course CI example, not a claim of a production pricing system.
|
||||||
|
|
||||||
|
Requirements: Python 3 (the Jenkins executor records its exact version), Git, and the Python standard library. No pip packages, Docker daemon, or Docker socket are needed for these checks.
|
||||||
|
|
||||||
|
From a clean clone, reproduce the Jenkins checks with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
python3 -m py_compile pricing.py tests/test_pricing.py
|
||||||
|
python3 -m unittest discover -s tests -v
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected: syntax check exits 0; three unit tests pass. The controlled demonstration changes multiplication to addition, causing the total and single-item tests to fail. The repair restores multiplication on the same PR.
|
||||||
|
|
||||||
|
Jenkins polls Gitea for PR updates. Its multibranch source tests PR heads (not synthetic merge commits) and publishes `startup-product-ci/pipeline/pr-main` for this PR to main. Branch protection requires that check and one real peer approval, dismisses stale approvals, and disallows direct pushes and admin merge bypass. Only trusted team members may change pipeline code. Builds execute on the controller in this resource-constrained course deployment; untrusted fork PR discovery is disabled.
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
def total_price(unit_price, quantity):
|
||||||
|
if quantity < 1:
|
||||||
|
raise ValueError("Quantity must be positive")
|
||||||
|
return unit_price * quantity
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from pricing import total_price
|
||||||
|
|
||||||
|
|
||||||
|
class PricingTests(unittest.TestCase):
|
||||||
|
def test_total(self):
|
||||||
|
self.assertEqual(total_price(10, 3), 30)
|
||||||
|
|
||||||
|
def test_single_item(self):
|
||||||
|
self.assertEqual(total_price(12.5, 1), 12.5)
|
||||||
|
|
||||||
|
def test_invalid_quantity(self):
|
||||||
|
for quantity in (0, -1):
|
||||||
|
with self.subTest(quantity=quantity):
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
total_price(10, quantity)
|
||||||
Reference in New Issue
Block a user