diff --git a/.github/workflows/npm.yaml b/.github/workflows/npm.yaml index d8d8902..de12059 100644 --- a/.github/workflows/npm.yaml +++ b/.github/workflows/npm.yaml @@ -10,10 +10,20 @@ jobs: node-version: 22 cache: npm - run: npm ci - - run: npm run build --if-present - - run: npm test -- --no-watch --no-progress --browsers=ChromeHeadless --code-coverage --reporters junit - - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() + - run: npm run build --if-present -- --base-href . + - uses: actions/upload-pages-artifact@v3 with: - files: TESTS-*.xml - + path: dist/tso-tools/browser + deploy: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + needs: build + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - uses: actions/deploy-pages@v4 + id: deployment diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml new file mode 100644 index 0000000..1812938 --- /dev/null +++ b/.github/workflows/pull_request.yaml @@ -0,0 +1,18 @@ +on: + pull_request: +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + - run: npm ci + - run: npm run build --if-present + - run: npm test -- --no-watch --no-progress --browsers=ChromeHeadless --code-coverage --reporters junit + - uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + files: TESTS-*.xml diff --git a/src/app/app.config.ts b/src/app/app.config.ts index 0e0aafe..9f54de2 100644 --- a/src/app/app.config.ts +++ b/src/app/app.config.ts @@ -1,5 +1,5 @@ import { ApplicationConfig, provideZoneChangeDetection, isDevMode } from '@angular/core'; -import { provideRouter } from '@angular/router'; +import { provideRouter, RouterFeatures, withHashLocation } from '@angular/router'; import { routes } from './app.routes'; import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; @@ -7,9 +7,15 @@ import { provideServiceWorker } from '@angular/service-worker'; import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; +const routerFeatures: RouterFeatures[] = []; + +// switch from the History API / pushState navigation if the base url is fully relative +const base = document.querySelector('base')?.getAttribute('href'); +if (!base?.startsWith('/') && !base?.includes('://')) routerFeatures.push(withHashLocation()); + export const appConfig: ApplicationConfig = { - providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), provideAnimationsAsync(), provideServiceWorker('ngsw-worker.js', { - enabled: !isDevMode(), - registrationStrategy: 'registerWhenStable:30000' - }), {provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: {duration: 2500}}] + providers: [provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes, ...routerFeatures), provideAnimationsAsync(), provideServiceWorker('ngsw-worker.js', { + enabled: !isDevMode(), + registrationStrategy: 'registerWhenStable:30000' + }), { provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: { duration: 2500 } }] };