Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d2fc39422a | ||
|
|
7e8b946ab4 | ||
|
|
d6c9385956 |
@@ -0,0 +1,13 @@
|
|||||||
|
.git
|
||||||
|
.gitea
|
||||||
|
.cpcache
|
||||||
|
.clj-kondo
|
||||||
|
.env
|
||||||
|
.token
|
||||||
|
.idea
|
||||||
|
log
|
||||||
|
node_modules
|
||||||
|
resources/public/css/output.css
|
||||||
|
target
|
||||||
|
*.iml
|
||||||
|
*.log
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
name: build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
tags: ['v*']
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: harbor.pmagnus.cloud
|
||||||
|
IMAGE: harbor.pmagnus.cloud/elprice/elprice
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: elprice
|
||||||
|
POSTGRES_USER: elprice
|
||||||
|
POSTGRES_PASSWORD: elprice
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U elprice -d elprice"
|
||||||
|
--health-interval 2s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 30
|
||||||
|
env:
|
||||||
|
TARGET_HOST: localhost
|
||||||
|
TARGET_PORT: "5432"
|
||||||
|
TARGET_DB: elprice
|
||||||
|
TARGET_USER: elprice
|
||||||
|
TARGET_PASSWORD: elprice
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
docker run --rm --network host \
|
||||||
|
-e TARGET_HOST -e TARGET_PORT -e TARGET_DB \
|
||||||
|
-e TARGET_USER -e TARGET_PASSWORD \
|
||||||
|
-v "$PWD:/app" -w /app \
|
||||||
|
clojure:temurin-21-tools-deps-alpine \
|
||||||
|
clojure -M:test
|
||||||
|
|
||||||
|
- name: Generate immutable tags
|
||||||
|
id: tags
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
SHA=$(git rev-parse --short HEAD)
|
||||||
|
case "$GITHUB_REF" in
|
||||||
|
refs/tags/v*) VERSION="${GITHUB_REF_NAME#v}" ;;
|
||||||
|
*) VERSION="main-$(date -u +%Y%m%d%H%M%S)" ;;
|
||||||
|
esac
|
||||||
|
echo "primary=$IMAGE:$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "qualified=$IMAGE:$VERSION-$SHA" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# The runner host has the pinned route to Harbor. Keep BuildKit on the
|
||||||
|
# host network until job containers can resolve and reach it directly.
|
||||||
|
- uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
driver-opts: network=host
|
||||||
|
|
||||||
|
- uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ secrets.HARBOR_ROBOT_USER }}
|
||||||
|
password: ${{ secrets.HARBOR_ROBOT_TOKEN }}
|
||||||
|
|
||||||
|
- uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.tags.outputs.primary }}
|
||||||
|
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
|
||||||
|
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
|
||||||
|
|
||||||
|
- name: Wait for Harbor policy, then add SHA tag
|
||||||
|
env:
|
||||||
|
PRIMARY: ${{ steps.tags.outputs.primary }}
|
||||||
|
QUALIFIED: ${{ steps.tags.outputs.qualified }}
|
||||||
|
run: |
|
||||||
|
for attempt in $(seq 1 60); do
|
||||||
|
if docker buildx imagetools inspect "$PRIMARY" >/dev/null 2>&1; then
|
||||||
|
docker buildx imagetools create --tag "$QUALIFIED" "$PRIMARY"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echo "waiting for Harbor scan/pull policy ($attempt/60)"
|
||||||
|
sleep 10
|
||||||
|
done
|
||||||
|
echo "Harbor did not approve $PRIMARY within 10 minutes" >&2
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
- name: Summary
|
||||||
|
run: echo "pushed ${{ steps.tags.outputs.primary }} and ${{ steps.tags.outputs.qualified }}"
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
name: pull-request
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
validate:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres:17-alpine
|
||||||
|
env:
|
||||||
|
POSTGRES_DB: elprice
|
||||||
|
POSTGRES_USER: elprice
|
||||||
|
POSTGRES_PASSWORD: elprice
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
options: >-
|
||||||
|
--health-cmd "pg_isready -U elprice -d elprice"
|
||||||
|
--health-interval 2s
|
||||||
|
--health-timeout 5s
|
||||||
|
--health-retries 30
|
||||||
|
env:
|
||||||
|
TARGET_HOST: localhost
|
||||||
|
TARGET_PORT: "5432"
|
||||||
|
TARGET_DB: elprice
|
||||||
|
TARGET_USER: elprice
|
||||||
|
TARGET_PASSWORD: elprice
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
docker run --rm --network host \
|
||||||
|
-e TARGET_HOST -e TARGET_PORT -e TARGET_DB \
|
||||||
|
-e TARGET_USER -e TARGET_PASSWORD \
|
||||||
|
-v "$PWD:/app" -w /app \
|
||||||
|
clojure:temurin-21-tools-deps-alpine \
|
||||||
|
clojure -M:test
|
||||||
|
|
||||||
|
- name: Build production image
|
||||||
|
run: docker build --platform linux/amd64 -t elprice:pr-check .
|
||||||
@@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
:deps {org.clojure/clojure {:mvn/version "1.12.3"}
|
:deps {org.clojure/clojure {:mvn/version "1.12.3"}
|
||||||
|
|
||||||
|
;; Security overrides for transitive web/runtime dependencies.
|
||||||
|
com.fasterxml.jackson.core/jackson-core {:mvn/version "2.21.4"}
|
||||||
|
com.fasterxml.jackson.core/jackson-databind {:mvn/version "2.21.4"}
|
||||||
|
io.undertow/undertow-core {:mvn/version "2.3.21.Final"}
|
||||||
|
org.jboss.xnio/xnio-api {:mvn/version "3.8.14.Final"}
|
||||||
|
org.jboss.xnio/xnio-nio {:mvn/version "3.8.14.Final"}
|
||||||
|
|
||||||
;; Routing
|
;; Routing
|
||||||
metosin/reitit {:mvn/version "0.9.2"}
|
metosin/reitit {:mvn/version "0.9.2"}
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,12 @@
|
|||||||
;; log uncaught exceptions in threads
|
;; log uncaught exceptions in threads
|
||||||
(Thread/setDefaultUncaughtExceptionHandler
|
(Thread/setDefaultUncaughtExceptionHandler
|
||||||
(fn [thread ex]
|
(fn [thread ex]
|
||||||
(log/error {:what :uncaught-exception
|
;; Integrant exceptions include component configuration in ex-data. Logging
|
||||||
:exception ex
|
;; the exception object can therefore disclose database or cookie secrets.
|
||||||
:where (str "Uncaught exception on" (.getName thread))})))
|
(log/error {:what :uncaught-exception
|
||||||
|
:exception-class (.getName (class ex))
|
||||||
|
:message (.getMessage ex)
|
||||||
|
:where (str "Uncaught exception on " (.getName thread))})))
|
||||||
|
|
||||||
|
|
||||||
(defonce system (atom nil))
|
(defonce system (atom nil))
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
(ns pmagnus.elprice.core-test
|
(ns pmagnus.elprice.core-test
|
||||||
(:require
|
(:require
|
||||||
[pmagnus.elprice.test-utils :as utils]
|
[clojure.test :refer [deftest is]]
|
||||||
[clojure.test :refer :all]))
|
[pmagnus.elprice.core :as core]))
|
||||||
|
|
||||||
(deftest example-test
|
|
||||||
(is (= 1 2)))
|
|
||||||
|
|
||||||
|
(deftest system-state-is-managed-in-an-atom
|
||||||
|
(is (instance? clojure.lang.Atom core/system)))
|
||||||
|
|||||||
Reference in New Issue
Block a user