Skip to content

Commit

Permalink
Merge branch 'main' into 47-create-logging-concept-for-front-ende8
Browse files Browse the repository at this point in the history
  • Loading branch information
Koufan-De-King authored Nov 18, 2024
2 parents 816f4b4 + f2089db commit 3227da2
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 6 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/analyses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
- name: TypeScript
run: npm run ts:check


# Step 5: Run unit tests
unit_tests:
needs: install # Depends on the install job
Expand All @@ -120,3 +121,50 @@ jobs:
# Run unit tests
- name: Unit tests
run: npm run test:unit

# Generate coverage report
- name: Generate Coverage Report
run: npm run coverage

# Upload coverage report
- name: Upload coverage Report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage

# Step 6: Run SonarQube analysis
sonarqube:
name: SonarQube Analysis
needs: [build, unit_tests]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

#Download coverage report
- name: Download coverage Report
uses: actions/download-artifact@v3
with:
name: coverage-report
path: coverage

# Run SonarQube analysis
- uses: sonarsource/sonarqube-scan-action@v3
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
with:
args: |
-Dsonar.projectKey=Webank-Userapp
-Dsonar.source=src
-Dsonar.javascript.lcov.reportPaths=coverage/lcov.info
-Dsonar.qualitygate.wait=true
#If you wish to fail your job when the Quality Gate is red
- uses: sonarsource/sonarqube-quality-gate-action@master
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
coverage
!coverage/lcov.info
!coverage/lcov-report

node_modules
dist
dist-ssr
dev-dist
*.local

.sonar
*.sonar
# Editor directories and files
.vscode/*
!.vscode/extensions.json
Expand Down
159 changes: 159 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"jsdom": "^25.0.1",
"postcss": "^8.4.47",
"prettier": "^3.3.3",
"sonarqube-scanner": "^4.2.5",
"tailwindcss": "^3.4.14",
"tslib": "^2.8.0",
"typescript": "^5.6.3",
Expand Down
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sonar.projectKey=Webank-Userapp
sonar.javascript.lcov.reportPaths=coverage/lcov.info
sonar.sources=src
sonar.tests=src
sonar.language=ts
sonar.inclusions=**/*.ts,**/*.tsx
sonar.test.inclusions=**/*.spec.js,**/*.test.js,**/*.spec.ts,**/*.test.ts
sonar.test.exclusions=**/node_modules/**
3 changes: 2 additions & 1 deletion src/services/keyManagement/storageSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ interface MyDatabase extends DBSchema {
key: number; // Represents a unique identifier for the key record
value: {
pub: JsonWebKey; // Public Key in JWK format
priv: JsonWebKey; // Private Key in JWK format
priv: JsonWebKey;
kid: number; // Private Key in JWK format
};
};
}
Expand Down
7 changes: 4 additions & 3 deletions src/services/keyManagement/storeKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ export async function storeKeyPair() {
value: {
pub: { ...publicKey },
priv: { ...privateKey },
kid: 1,
},
});
}

// Function to retrieve the key pair from IndexedDB
export async function retrieveKeyPair(id: number) {
const retrievedRecord = await storage.findOne("keys", id);
export async function retrieveKeyPair(kid: number) {
const retrievedRecord = await storage.findOne("keys", kid);

if (retrievedRecord) {
const { pub: publicKey, priv: privateKey } = retrievedRecord.value;

return { publicKey, privateKey };
} else {
console.error("No key pair found with key ID:", id);
console.error("No key pair found with key ID:", kid);
}

return { publicKey: null, privateKey: null };
Expand Down
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default defineConfig({
environment: "happy-dom",
coverage: {
provider: "v8",
reporter: ["text", "json", "html"],
reporter: ["text", "json", "html","lcov"],
reportsDirectory: 'coverage',
all: true,
},
setupFiles: ["./vitest.setup.ts"],
Expand Down

0 comments on commit 3227da2

Please sign in to comment.