Compare commits

..

2 Commits

Author SHA1 Message Date
Constantin Graf
7ae4f2171d Fix for tests 2025-05-16 15:48:58 +02:00
Constantin Graf
96acd4b962 Add parallel testing to GitHub action phpunit 2025-05-16 15:48:58 +02:00
23 changed files with 69 additions and 159 deletions

View File

@@ -10,8 +10,6 @@ on:
- '.github/workflows/build-private.yml' - '.github/workflows/build-private.yml'
- 'docker/prod/**' - 'docker/prod/**'
workflow_dispatch: workflow_dispatch:
permissions:
contents: read
name: Build - Private name: Build - Private
jobs: jobs:
@@ -19,7 +17,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- name: "Check out code" - name: "Check out code"
uses: actions/checkout@v4 uses: actions/checkout@v4

View File

@@ -11,12 +11,6 @@ on:
- 'docker/prod/**' - 'docker/prod/**'
workflow_dispatch: workflow_dispatch:
permissions:
packages: write
contents: read
attestations: write
id-token: write
env: env:
DOCKERHUB_REPO: solidtime/solidtime DOCKERHUB_REPO: solidtime/solidtime
GHCR_REPO: ghcr.io/solidtime-io/solidtime GHCR_REPO: ghcr.io/solidtime-io/solidtime
@@ -32,6 +26,11 @@ jobs:
- runs-on: "ubuntu-24.04" - runs-on: "ubuntu-24.04"
platform: "linux/amd64" platform: "linux/amd64"
runs-on: ${{ matrix.runs-on }} runs-on: ${{ matrix.runs-on }}
permissions:
packages: write
contents: read
attestations: write
id-token: write
timeout-minutes: 90 timeout-minutes: 90
steps: steps:
@@ -164,6 +163,11 @@ jobs:
merge: merge:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
packages: write
contents: read
attestations: write
id-token: write
timeout-minutes: 90 timeout-minutes: 90
needs: needs:
- build - build

View File

@@ -3,9 +3,6 @@ on:
push: push:
branches: branches:
- main - main
permissions:
contents: read
jobs: jobs:
api_docs: api_docs:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,8 +1,6 @@
name: NPM Build name: NPM Build
on: [push] on: [push]
permissions:
contents: read
jobs: jobs:
build: build:

View File

@@ -1,8 +1,6 @@
name: NPM Lint name: NPM Lint
on: [push] on: [push]
permissions:
contents: read
jobs: jobs:
build: build:

View File

@@ -1,8 +1,6 @@
name: Publish API package to NPM name: Publish API package to NPM
on: on:
workflow_dispatch workflow_dispatch
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,8 +1,6 @@
name: Publish UI package to NPM name: Publish UI package to NPM
on: on:
workflow_dispatch workflow_dispatch
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,8 +1,7 @@
name: NPM Typecheck name: NPM Typecheck
on: [push] on: [push]
permissions:
contents: read
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,7 +1,5 @@
name: Static code analysis (PHPStan) name: Static code analysis (PHPStan)
on: push on: push
permissions:
contents: read
jobs: jobs:
phpstan: phpstan:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,18 +1,13 @@
name: PHPUnit Tests name: PHPUnit Tests
on: push on: push
permissions:
contents: read
jobs: jobs:
phpunit: phpunit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 10 timeout-minutes: 10
strategy:
matrix:
postgres_version: [ 15, 16, 17 ]
services: services:
pgsql_test: pgsql_test:
image: postgres:${{ matrix.postgres_version }} image: postgres:15
env: env:
PGPASSWORD: 'root' PGPASSWORD: 'root'
POSTGRES_DB: 'laravel' POSTGRES_DB: 'laravel'
@@ -65,10 +60,10 @@ jobs:
php artisan passport:keys php artisan passport:keys
- name: "Run PHPUnit" - name: "Run PHPUnit"
run: php artisan test --stop-on-failure --coverage-text --coverage-clover=coverage.xml run: php artisan test --parallel --stop-on-failure --coverage-text --coverage-clover=coverage.xml
- name: "Upload coverage reports to Codecov" - name: "Upload coverage reports to Codecov"
uses: codecov/codecov-action@v5.4.3 uses: codecov/codecov-action@v5.4.2
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
slug: solidtime-io/solidtime slug: solidtime-io/solidtime

View File

@@ -1,7 +1,5 @@
name: PHP Linting name: PHP Linting
on: push on: push
permissions:
contents: read
jobs: jobs:
pint: pint:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -1,7 +1,5 @@
name: Playwright Tests name: Playwright Tests
on: [push] on: [push]
permissions:
contents: read
jobs: jobs:
test: test:
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -23,7 +23,6 @@ use Filament\Tables;
use Filament\Tables\Filters\TernaryFilter; use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent; use Korridor\LaravelModelValidationRules\Rules\UniqueEloquent;
@@ -208,14 +207,6 @@ class UserResource extends Resource
}), }),
]) ])
->bulkActions([ ->bulkActions([
Tables\Actions\BulkAction::make('Resend verification email')
->icon('heroicon-o-paper-airplane')
->action(function (Collection $records): void {
foreach ($records as $user) {
/** @var User $user */
$user->sendEmailVerificationNotification();
}
}),
]); ]);
} }

View File

@@ -17,7 +17,7 @@ import {
TooltipComponent, TooltipComponent,
} from 'echarts/components'; } from 'echarts/components';
import type { AggregatedTimeEntries, Organization } from '@/packages/api/src'; import type { AggregatedTimeEntries, Organization } from '@/packages/api/src';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from '@vueuse/core';
use([ use([
CanvasRenderer, CanvasRenderer,
@@ -47,10 +47,8 @@ const xAxisLabels = computed(() => {
formatDate(el.key ?? '', organization?.value?.date_format) formatDate(el.key ?? '', organization?.value?.date_format)
); );
}); });
const accentColor = useCssVariable('--theme-color-chart'); const accentColor = useCssVar('--theme-color-chart', null, { observe: true });
const labelColor = useCssVariable('--color-text-secondary'); const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
const markLineColor = useCssVariable('--color-border-secondary');
const splitLineColor = useCssVariable('--color-border-tertiary');
const seriesData = computed(() => { const seriesData = computed(() => {
return props?.groupedData?.map((el) => { return props?.groupedData?.map((el) => {
@@ -113,7 +111,7 @@ const option = computed(() => ({
data: xAxisLabels.value, data: xAxisLabels.value,
markLine: { markLine: {
lineStyle: { lineStyle: {
color: markLineColor.value, color: 'rgba(125,156,188,0.1)',
type: 'dashed', type: 'dashed',
}, },
}, },
@@ -137,13 +135,9 @@ const option = computed(() => ({
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
axisLabel: {
color: labelColor.value,
fontFamily: 'Outfit, sans-serif',
},
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: splitLineColor.value, color: 'rgba(125,156,188,0.2)', // Set desired color here
}, },
}, },
}, },

View File

@@ -11,7 +11,7 @@ import {
TooltipComponent, TooltipComponent,
} from 'echarts/components'; } from 'echarts/components';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time'; import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from '@vueuse/core';
import type { Organization } from '@/packages/api/src'; import type { Organization } from '@/packages/api/src';
use([ use([
@@ -36,7 +36,7 @@ type ReportingChartDataEntry = {
const props = defineProps<{ const props = defineProps<{
data: ReportingChartDataEntry | null; data: ReportingChartDataEntry | null;
}>(); }>();
const labelColor = useCssVariable('--color-text-secondary'); const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
const seriesData = computed(() => { const seriesData = computed(() => {
return props.data?.map((el) => { return props.data?.map((el) => {

View File

@@ -19,7 +19,7 @@ import {
formatHumanReadableDuration, formatHumanReadableDuration,
getDayJsInstance, getDayJsInstance,
} from '@/packages/ui/src/utils/time'; } from '@/packages/ui/src/utils/time';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from '@vueuse/core';
import { useQuery } from '@tanstack/vue-query'; import { useQuery } from '@tanstack/vue-query';
import { getCurrentOrganizationId } from '@/utils/useUser'; import { getCurrentOrganizationId } from '@/utils/useUser';
import { api, type Organization } from '@/packages/api/src'; import { api, type Organization } from '@/packages/api/src';
@@ -64,9 +64,12 @@ const max = computed(() => {
} }
}); });
const backgroundColor = useCssVariable('--theme-color-card-background'); const backgroundColor = useCssVar('--color-card-background', null, {
const itemBackgroundColor = useCssVariable('--color-bg-tertiary'); observe: true,
const borderColor = useCssVariable('--color-border'); });
const itemBackgroundColor = useCssVar('--color-bg-tertiary', null, {
observe: true,
});
const option = computed(() => { const option = computed(() => {
return { return {
@@ -117,7 +120,7 @@ const option = computed(() => {
[], [],
itemStyle: { itemStyle: {
borderRadius: 5, borderRadius: 5,
borderColor: borderColor.value, borderColor: 'rgba(255,255,255,0.05)',
borderWidth: 1, borderWidth: 1,
}, },
tooltip: { tooltip: {

View File

@@ -1,14 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import VChart from 'vue-echarts'; import VChart from 'vue-echarts';
import { computed } from 'vue'; import { computed, ref } from 'vue';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from '@vueuse/core';
const props = defineProps<{ const props = defineProps<{
history: number[]; history: number[];
}>(); }>();
const accentColor = useCssVariable('--theme-color-chart'); const accentColor = useCssVar('--theme-color-chart', null, { observe: true });
const markLineColor = useCssVariable('--color-border-secondary');
const seriesData = computed(() => props.history.map((el) => { const seriesData = computed(() => props.history.map((el) => {
return { return {
@@ -23,7 +22,7 @@ const seriesData = computed(() => props.history.map((el) => {
}, },
}; };
})); }));
const option = computed(() => ({ const option = ref({
grid: { grid: {
top: 0, top: 0,
right: 0, right: 0,
@@ -36,7 +35,7 @@ const option = computed(() => ({
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
markLine: { markLine: {
lineStyle: { lineStyle: {
color: markLineColor.value, color: 'rgba(125,156,188,0.1)',
type: 'dashed', type: 'dashed',
}, },
}, },
@@ -67,11 +66,11 @@ const option = computed(() => ({
}, },
series: [ series: [
{ {
data: seriesData.value, data: seriesData,
type: 'bar', type: 'bar',
}, },
], ],
})); });
</script> </script>
<template> <template>

View File

@@ -11,7 +11,7 @@ import {
TooltipComponent, TooltipComponent,
} from 'echarts/components'; } from 'echarts/components';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time'; import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from "@vueuse/core";
import type { Organization } from "@/packages/api/src"; import type { Organization } from "@/packages/api/src";
use([ use([
@@ -24,7 +24,7 @@ use([
]); ]);
provide(THEME_KEY, 'dark'); provide(THEME_KEY, 'dark');
const labelColor = useCssVariable('--color-text-secondary'); const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
const props = defineProps<{ const props = defineProps<{
weeklyProjectOverview: { weeklyProjectOverview: {

View File

@@ -18,7 +18,7 @@ import ProjectsChartCard from '@/Components/Dashboard/ProjectsChartCard.vue';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time'; import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { formatCents } from '@/packages/ui/src/utils/money'; import { formatCents } from '@/packages/ui/src/utils/money';
import { getWeekStart } from '@/packages/ui/src/utils/settings'; import { getWeekStart } from '@/packages/ui/src/utils/settings';
import { useCssVariable } from '@/utils/useCssVariable'; import { useCssVar } from '@vueuse/core';
import { getOrganizationCurrencyString } from '@/utils/money'; import { getOrganizationCurrencyString } from '@/utils/money';
import { useQuery } from '@tanstack/vue-query'; import { useQuery } from '@tanstack/vue-query';
import { getCurrentOrganizationId } from '@/utils/useUser'; import { getCurrentOrganizationId } from '@/utils/useUser';
@@ -60,7 +60,7 @@ const weekdays = computed(() => {
} }
}); });
const accentColor = useCssVariable('--theme-color-chart'); const accentColor = useCssVar('--theme-color-chart', null, { observe: true });
// Get the organization ID using the utility function // Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId()); const organizationId = computed(() => getCurrentOrganizationId());
@@ -176,8 +176,10 @@ const seriesData = computed(() => {
}); });
}); });
const markLineColor = useCssVariable('--color-border-secondary'); const markLineColor = useCssVar('--color-border-secondary', null, {
const labelColor = useCssVariable('--color-text-secondary'); observe: true,
});
const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
const option = computed(() => { const option = computed(() => {
return { return {
tooltip: { tooltip: {
@@ -213,10 +215,6 @@ const option = computed(() => {
}, },
yAxis: { yAxis: {
type: 'value', type: 'value',
axisLabel: {
color: labelColor.value,
fontFamily: 'Outfit, sans-serif',
},
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: markLineColor.value, color: markLineColor.value,

View File

@@ -5,7 +5,10 @@ import {
PopoverTrigger, PopoverTrigger,
} from '@/Components/ui/popover'; } from '@/Components/ui/popover';
import { RangeCalendar } from '@/Components/ui/range-calendar'; import { RangeCalendar } from '@/Components/ui/range-calendar';
import { CalendarDate } from '@internationalized/date'; import {
CalendarDate,
getLocalTimeZone,
} from '@internationalized/date';
import { CalendarIcon } from 'lucide-vue-next'; import { CalendarIcon } from 'lucide-vue-next';
import { computed, ref, inject, type ComputedRef, watch } from 'vue'; import { computed, ref, inject, type ComputedRef, watch } from 'vue';
import { twMerge } from 'tailwind-merge'; import { twMerge } from 'tailwind-merge';
@@ -13,9 +16,8 @@ import {
getDayJsInstance, getDayJsInstance,
getLocalizedDayJs, getLocalizedDayJs,
} from '@/packages/ui/src/utils/time'; } from '@/packages/ui/src/utils/time';
import { formatDateLocalized } from '@/packages/ui/src/utils/time';
import { type Organization } from '@/packages/api/src'; import { type Organization } from '@/packages/api/src';
import { getUserTimezone } from '@/packages/ui/src/utils/settings';
import { formatDate } from '@/packages/ui/src/utils/time';
const props = defineProps<{ const props = defineProps<{
start: string; start: string;
@@ -57,13 +59,12 @@ const modelValue = computed<CalendarDateRange>({
}), }),
set: (newValue) => { set: (newValue) => {
if (newValue.start) { if (newValue.start) {
console.log(newValue.start); const date = newValue.start.toDate(getLocalTimeZone());
const date = newValue.start.toDate(getUserTimezone()); emit('update:start', getDayJsInstance()(date).format('YYYY-MM-DD'));
emit('update:start', getLocalizedDayJs(date.toString()).format());
} }
if (newValue.end) { if (newValue.end) {
const date = newValue.end.toDate(getUserTimezone()); const date = newValue.end.toDate(getLocalTimeZone());
emit('update:end', getLocalizedDayJs(date.toString()).format()); emit('update:end', getDayJsInstance()(date).format('YYYY-MM-DD'));
} }
}, },
}); });
@@ -218,27 +219,12 @@ watch(open, (value) => {
<CalendarIcon class="mr-2 h-4 w-4" /> <CalendarIcon class="mr-2 h-4 w-4" />
<template v-if="modelValue.start"> <template v-if="modelValue.start">
<template v-if="modelValue.end"> <template v-if="modelValue.end">
{{ {{ formatDateLocalized(modelValue.start.toString(), organization?.date_format) }}
formatDate(
modelValue.start.toString(),
organization?.date_format
)
}}
- -
{{ {{ formatDateLocalized(modelValue.end.toString(), organization?.date_format) }}
formatDate(
modelValue.end.toString(),
organization?.date_format
)
}}
</template> </template>
<template v-else> <template v-else>
{{ {{ formatDateLocalized(modelValue.start.toString(), organization?.date_format) }}
formatDate(
modelValue.start.toString(),
organization?.date_format
)
}}
</template> </template>
</template> </template>
<template v-else> Pick a date </template> <template v-else> Pick a date </template>

View File

@@ -3,6 +3,13 @@ import { computed, watch } from "vue";
type themeOption = "system" | "light" | "dark"; type themeOption = "system" | "light" | "dark";
const themeSetting = useStorage<themeOption>("theme", "system"); const themeSetting = useStorage<themeOption>("theme", "system");
// reload page when themeSettingChanges
watch(
themeSetting,
() => {
location.reload();
}
)
const preferredColor = usePreferredColorScheme(); const preferredColor = usePreferredColorScheme();
const theme = computed(() => { const theme = computed(() => {
if(themeSetting.value === "system"){ if(themeSetting.value === "system"){

View File

@@ -1,49 +0,0 @@
import { ref, onMounted, onUnmounted } from 'vue'
export function useCssVariable(variableName: string) {
const value = ref('')
let observer: MutationObserver | null = null
let mediaQuery: MediaQueryList | null = null
const updateValue = () => {
const computedStyle = getComputedStyle(document.documentElement)
const cssValue = computedStyle.getPropertyValue(variableName).trim()
value.value = cssValue
}
onMounted(() => {
// Initialize with current value
updateValue()
// Watch for class changes on document.documentElement (where theme classes are applied)
observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
updateValue()
}
})
})
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ['class']
})
// Also watch for system color scheme changes
if (window.matchMedia) {
mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
mediaQuery.addEventListener('change', updateValue)
}
})
onUnmounted(() => {
if (observer) {
observer.disconnect()
}
if (mediaQuery) {
mediaQuery.removeEventListener('change', updateValue)
}
})
return value
}

View File

@@ -12,12 +12,12 @@ use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\UsesClass; use PHPUnit\Framework\Attributes\UsesClass;
use Tests\TestCase; use Tests\TestCaseWithDatabase;
#[CoversClass(SelfHostTelemetryCommand::class)] #[CoversClass(SelfHostTelemetryCommand::class)]
#[CoversClass(ApiService::class)] #[CoversClass(ApiService::class)]
#[UsesClass(SelfHostTelemetryCommand::class)] #[UsesClass(SelfHostTelemetryCommand::class)]
class SelfHostTelemetryCommandTest extends TestCase class SelfHostTelemetryCommandTest extends TestCaseWithDatabase
{ {
public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void public function test_telemetry_sends_data_to_telemetry_endpoint_of_solidtime_cloud(): void
{ {
@@ -30,9 +30,12 @@ class SelfHostTelemetryCommandTest extends TestCase
$exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry'); $exitCode = $this->withoutMockingConsoleOutput()->artisan('self-host:telemetry');
// Assert // Assert
$this->assertSame(Command::SUCCESS, $exitCode);
$output = Artisan::output(); $output = Artisan::output();
$this->assertSame('', $output); $this->assertSame('', $output);
if ($exitCode !== Command::SUCCESS) {
dump($output);
}
$this->assertSame(Command::SUCCESS, $exitCode);
} }
public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void public function test_telemetry_sends_fails_gracefully_if_response_has_error_status_code(): void