Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ usage() {
echo " --all check all tracked files" >&2
}

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT" || exit 1

case "${1:-}" in
"")
selected_files=$(git diff --cached --name-only --diff-filter=ACMR)
selected_files=$(git diff --cached --name-only --diff-filter=ACDMR)
mode_label="staged"
;;
--unstaged)
selected_files=$(git diff --name-only --diff-filter=ACMR)
selected_files=$(git diff --name-only --diff-filter=ACDMR)
selected_files="$selected_files
$(git ls-files --others --exclude-standard)"
mode_label="unstaged"
Expand All @@ -29,9 +32,6 @@ $(git ls-files --others --exclude-standard)"
;;
esac

REPO_ROOT=$(git rev-parse --show-toplevel)
cd "$REPO_ROOT" || exit 1

TMP_ROOT=${TMPDIR:-/tmp}/tests-dcompose
mkdir -p "$TMP_ROOT"
PIDS_FILE=$(mktemp "$TMP_ROOT/dcompose-precommit.XXXXXX")
Expand Down Expand Up @@ -96,14 +96,14 @@ fi

if [ "$go_changed" -eq 1 ]; then
run_step "Go: Formatter" mise exec -- golangci-lint fmt --diff ./cmd/... ./internal/...
run_step "Go: Tests" mise exec -- go test -race ./cmd/... ./internal/...
run_step "Go: Tests" mise exec -- go test -race -shuffle=on ./cmd/... ./internal/...
run_step "Go: Linter" mise exec -- golangci-lint run ./cmd/... ./internal/...
fi

if [ "$frontend_changed" -eq 1 ]; then
run_step "Frontend: Formatter" mise exec -- bun --cwd="$PWD/frontend/" run format:check
run_step "Frontend: Linter" mise exec -- bun --cwd="$PWD/frontend/" run lint
run_step "Frontend: Tests" mise exec -- bun --cwd="$PWD/frontend/" test
run_step "Frontend: Tests" mise exec -- bun --cwd="$PWD/frontend/" test --randomize
run_step "Frontend: TSC" mise exec -- bun --cwd="$PWD/frontend/" run lint:tsc
fi

Expand Down
13 changes: 13 additions & 0 deletions .github/scripts/build-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -euo pipefail

version=${GITHUB_REF##*/}
commit_sha=$(git rev-parse HEAD)
build_date=$(date -u +%Y-%m-%d)
branch=$(git branch --show-current)
if [[ "$GITHUB_REF" == refs/heads/* ]]; then
branch=${GITHUB_REF#refs/heads/}
fi

printf 'version=%s\ncommit_sha=%s\nbuild_date=%s\nbranch=%s\n' \
"$version" "$commit_sha" "$build_date" "${branch:-unknown}"
11 changes: 10 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
branches:
- master
- dev
- testing
paths-ignore:
- '**.md'
- '.github/ISSUE_TEMPLATE/**'
Expand All @@ -22,6 +21,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v7

- name: Read build metadata
id: build-info
run: bash .github/scripts/build-info.sh >> "$GITHUB_OUTPUT"

- name: Set up tools
uses: jdx/mise-action@v5
with:
Expand Down Expand Up @@ -60,6 +63,11 @@ jobs:
run: ./.githooks/pre-commit --all

- name: Build frontend
env:
NUXT_PUBLIC_VERSION: ${{ steps.build-info.outputs.version }}
NUXT_PUBLIC_COMMIT_SHA: ${{ steps.build-info.outputs.commit_sha }}
NUXT_PUBLIC_BUILD_DATE: ${{ steps.build-info.outputs.build_date }}
NUXT_PUBLIC_BRANCH: ${{ steps.build-info.outputs.branch }}
run: bun --cwd=$PWD/frontend/ run generate

- name: Set up Docker Buildx
Expand All @@ -74,3 +82,4 @@ jobs:
cache-from: type=gha,scope=${{ github.workflow }}
cache-to: type=gha,mode=max,scope=${{ github.workflow }}
provenance: false
build-args: VERSION=${{ steps.build-info.outputs.version }}
15 changes: 13 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
type: boolean
default: false
push:
branches: [dev, master, testing]
branches: [dev, master]
tags: ['v*']
paths-ignore:
- '**.md'
Expand Down Expand Up @@ -47,9 +47,15 @@ jobs:
needs: validate-build-config
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
version: ${{ steps.build-info.outputs.version }}
steps:
- uses: actions/checkout@v7

- name: Read build metadata
id: build-info
run: bash .github/scripts/build-info.sh >> "$GITHUB_OUTPUT"

- uses: jdx/mise-action@v5
with:
install_args: go bun node golangci-lint
Expand Down Expand Up @@ -84,6 +90,11 @@ jobs:
run: ./.githooks/pre-commit --all

- name: Build frontend
env:
NUXT_PUBLIC_VERSION: ${{ steps.build-info.outputs.version }}
NUXT_PUBLIC_COMMIT_SHA: ${{ steps.build-info.outputs.commit_sha }}
NUXT_PUBLIC_BUILD_DATE: ${{ steps.build-info.outputs.build_date }}
NUXT_PUBLIC_BRANCH: ${{ steps.build-info.outputs.branch }}
run: bun --cwd=$PWD/frontend/ generate

- name: Upload frontend build (GitHub)
Expand All @@ -110,7 +121,7 @@ jobs:
env:
CGO_ENABLED: '0'
GOOS: linux
VERSION: ${{ github.ref_name }}
VERSION: ${{ needs.test.outputs.version }}
steps:
- uses: actions/checkout@v7

Expand Down
52 changes: 52 additions & 0 deletions frontend/app/components/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRuntimeConfig } from '#app'
import { NuxtLink } from '#components'
import UIcon from '@nuxt/ui/components/Icon.vue'
import UTooltip from '@nuxt/ui/components/Tooltip.vue'

const projectUrl = 'https://github.com/arabcoders/dcompose'
const runtimeConfig = useRuntimeConfig()
const version = computed(() => runtimeConfig.public.version)
const buildDate = computed(() => runtimeConfig.public.buildDate)
const branch = computed(() => runtimeConfig.public.branch)
const commitSha = computed(() => runtimeConfig.public.commitSha)
const hasCommit = computed(() => '' !== commitSha.value && 'unknown' !== commitSha.value)
const shortCommit = computed(() => commitSha.value.slice(0, 7))
const commitUrl = computed(() => `${projectUrl}/commit/${commitSha.value}`)
</script>

<template>
<footer class="mt-auto border-t border-default pt-6 text-xs text-muted">
<div class="flex flex-wrap items-center gap-x-3 gap-y-1">
<NuxtLink
:to="projectUrl"
target="_blank"
rel="noopener noreferrer"
class="inline-flex items-center gap-2 font-semibold text-highlighted"
>
<UIcon name="i-lucide-github" class="size-4" />
<span>DCompose</span>
</NuxtLink>
<span class="flex flex-wrap items-center gap-x-2 gap-y-1">
<span>{{ version }}</span>
<span aria-hidden="true">·</span>
<span>{{ buildDate }}</span>
<span aria-hidden="true">·</span>
<UTooltip v-if="hasCommit" :text="commitSha">
<NuxtLink
:to="commitUrl"
target="_blank"
rel="noopener noreferrer"
class="hover:text-primary hover:underline"
>
{{ shortCommit }}
</NuxtLink>
</UTooltip>
<span v-else>unknown</span>
<span aria-hidden="true">·</span>
<span>{{ branch }}</span>
</span>
</div>
</footer>
</template>
Loading
Loading