generated from mathias/template-go-web
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c9bc1be31 | ||
|
|
308f71b566 |
@@ -7,9 +7,6 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
env:
|
|
||||||
IMAGE: hostexecutor
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check:
|
check:
|
||||||
name: Lint / Test / Vet
|
name: Lint / Test / Vet
|
||||||
@@ -31,85 +28,3 @@ jobs:
|
|||||||
|
|
||||||
- name: Run checks
|
- name: Run checks
|
||||||
run: task check
|
run: task check
|
||||||
|
|
||||||
build:
|
|
||||||
name: Build & Import
|
|
||||||
needs: check
|
|
||||||
runs-on: self-hosted
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
outputs:
|
|
||||||
image-tag: ${{ steps.meta.outputs.sha-tag }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Derive image tags
|
|
||||||
id: meta
|
|
||||||
run: |
|
|
||||||
SHA=$(git rev-parse --short HEAD)
|
|
||||||
echo "sha-tag=${SHA}" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Build and push to local registry
|
|
||||||
run: |
|
|
||||||
REGISTRY="localhost:5000"
|
|
||||||
REF="${REGISTRY}/${{ env.IMAGE }}:${{ steps.meta.outputs.sha-tag }}"
|
|
||||||
buildah build \
|
|
||||||
--label "org.opencontainers.image.revision=${{ github.sha }}" \
|
|
||||||
-t ${REF} \
|
|
||||||
-t ${REGISTRY}/${{ env.IMAGE }}:latest \
|
|
||||||
.
|
|
||||||
buildah push --tls-verify=false ${REF}
|
|
||||||
buildah push --tls-verify=false ${REGISTRY}/${{ env.IMAGE }}:latest
|
|
||||||
echo "✓ Image pushed to ${REF}"
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
name: Deploy via GitOps
|
|
||||||
needs: build
|
|
||||||
runs-on: self-hosted
|
|
||||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
|
||||||
steps:
|
|
||||||
- name: Update image tag in infra repo
|
|
||||||
env:
|
|
||||||
IMAGE_TAG: ${{ needs.build.outputs.image-tag }}
|
|
||||||
DEPLOY_KEY: ${{ secrets.INFRA_DEPLOY_KEY }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
echo "$DEPLOY_KEY" > ~/.ssh/id_infra
|
|
||||||
chmod 600 ~/.ssh/id_infra
|
|
||||||
ssh-keyscan -p 30022 10.0.1.20 >> ~/.ssh/known_hosts 2>/dev/null
|
|
||||||
export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_infra -o IdentitiesOnly=yes"
|
|
||||||
rm -rf /tmp/infra
|
|
||||||
git clone -b main ssh://git@10.0.1.20:30022/mathias/infra.git /tmp/infra
|
|
||||||
cd /tmp/infra
|
|
||||||
DEPLOYMENT="k3s/apps/hostexecutor/deployment.yaml"
|
|
||||||
sed -i "s|image: localhost:5000/hostexecutor:.*|image: localhost:5000/hostexecutor:${IMAGE_TAG}|" "$DEPLOYMENT"
|
|
||||||
grep -q "localhost:5000/hostexecutor:${IMAGE_TAG}" "$DEPLOYMENT" \
|
|
||||||
|| { echo "✗ image tag patch failed"; exit 1; }
|
|
||||||
if git diff --quiet "$DEPLOYMENT"; then
|
|
||||||
echo "ℹ image tag unchanged — skipping push"
|
|
||||||
else
|
|
||||||
git -c user.name="hostexecutor CI" \
|
|
||||||
-c user.email="ci@hostexecutor.local" \
|
|
||||||
commit -m "chore(deploy): hostexecutor → ${IMAGE_TAG}" "$DEPLOYMENT"
|
|
||||||
git push origin main
|
|
||||||
echo "✓ pushed to infra repo"
|
|
||||||
fi
|
|
||||||
shred -u ~/.ssh/id_infra
|
|
||||||
|
|
||||||
- name: Trigger Flux reconcile
|
|
||||||
run: |
|
|
||||||
kubectl -n flux-system annotate gitrepository flux-system \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
kubectl -n flux-system annotate kustomization apps \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
|
|
||||||
- name: Verify rollout
|
|
||||||
run: |
|
|
||||||
kubectl rollout status deployment/hostexecutor \
|
|
||||||
--namespace hostexecutor \
|
|
||||||
--timeout=120s \
|
|
||||||
|| {
|
|
||||||
kubectl get pods -n hostexecutor -o wide
|
|
||||||
kubectl get events -n hostexecutor --sort-by='.lastTimestamp' | tail -20
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-1
@@ -43,7 +43,7 @@ tasks:
|
|||||||
cmds: [.venv/bin/python scripts/fetch_multipair.py]
|
cmds: [.venv/bin/python scripts/fetch_multipair.py]
|
||||||
data:prepare:pair:
|
data:prepare:pair:
|
||||||
desc: "Build {PAIR}_hourly.parquet from data/raw/{PAIR}/ (e.g. PAIR=gbpusd)"
|
desc: "Build {PAIR}_hourly.parquet from data/raw/{PAIR}/ (e.g. PAIR=gbpusd)"
|
||||||
cmds: [PAIR={{.PAIR}} .venv/bin/python scripts/prepare_hourly.py {{.EXTRA_ARGS}}]
|
cmds: ["PAIR={{.PAIR}} .venv/bin/python scripts/prepare_hourly.py {{.EXTRA_ARGS}}"]
|
||||||
vars:
|
vars:
|
||||||
PAIR: '{{default "eurusd" .PAIR}}'
|
PAIR: '{{default "eurusd" .PAIR}}'
|
||||||
data:prepare:multipair:
|
data:prepare:multipair:
|
||||||
|
|||||||
@@ -40,11 +40,11 @@ func kupiecPOF(n, n1 int, p0 float64) float64 {
|
|||||||
phat := float64(n1) / float64(n)
|
phat := float64(n1) / float64(n)
|
||||||
|
|
||||||
var lr float64
|
var lr float64
|
||||||
switch {
|
switch n1 {
|
||||||
case n1 == 0:
|
case 0:
|
||||||
// 0 × ln(0/p0) = 0 by convention; only the n0 term contributes
|
// 0 × ln(0/p0) = 0 by convention; only the n0 term contributes
|
||||||
lr = 2 * float64(n0) * math.Log((1-phat)/(1-p0))
|
lr = 2 * float64(n0) * math.Log((1-phat)/(1-p0))
|
||||||
case n1 == n:
|
case n:
|
||||||
// n0 term vanishes
|
// n0 term vanishes
|
||||||
lr = 2 * float64(n1) * math.Log(phat/p0)
|
lr = 2 * float64(n1) * math.Log(phat/p0)
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user