Skip to content

Commit

Permalink
Merge pull request #2164 from headlamp-k8s/fix-tests
Browse files Browse the repository at this point in the history
Makefile: github/workflows/frontend: Add i18n-check to CI
  • Loading branch information
joaquimrocha authored Jul 16, 2024
2 parents 973e684 + 32c4a21 commit f689aca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ jobs:
run: |
make frontend-test
- name: Run frontend-i18n-check
run: |
make frontend-i18n-check
build:
name: build
runs-on: ${{ matrix.os }}
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ frontend-fixlint:
frontend-tsc:
cd frontend && npm run tsc

.PHONY: frontend-i18n-check
frontend-i18n-check:
@echo "Checking translations. If this fails use: 'npm run i18n'"
cd frontend && npm run i18n -- --fail-on-update

frontend-test:
cd frontend && npm run test -- --coverage

Expand Down
17 changes: 0 additions & 17 deletions frontend/src/i18n/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { execSync } from 'child_process';
import { error } from 'console';
import fs from 'fs';
import * as glob from 'glob';

const path = require('node:path');
const allowlist = require('./allowlist.json');

const frontendDir = path.join(__dirname, '..', '..');

/*
* Description:
* This test will check for duplicate keys in the translation files and will fail if any are found.
Expand Down Expand Up @@ -120,17 +117,3 @@ describe('Test for non-intentional repeating translation keys', () => {
expect(result).toBe(true);
});
});

function getTranslationChanges() {
// Get uncommitted changes in the tracked translation files.
return execSync(
`git status -uno --porcelain ${frontendDir}/src/i18n/locales/*/*.json`
).toString();
}

describe('Forgotten translations', () => {
test('Check uncommitted translations', async () => {
execSync('npm run i18n', { cwd: frontendDir });
expect(getTranslationChanges()).toBe('');
});
});

0 comments on commit f689aca

Please sign in to comment.