-
Notifications
You must be signed in to change notification settings - Fork 0
test(app): configure testing environment and add unit tests across entire app #108 and CI #136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: CI Pipeline | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@v3 | ||
| with: | ||
| node-version: "20" | ||
|
|
||
| - name: Install dependencies | ||
| run: npm install | ||
|
|
||
| # - name: Run tests | ||
| # run: npm run test | ||
|
|
||
| - name: Build Next.js app | ||
| run: npm run build | ||
|
|
||
| build-docker: | ||
| if: ${{ github.ref == 'refs/heads/main' }} | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: gcr.io/kaniko-project/executor:latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Set up Kaniko Configuration | ||
| run: | | ||
| mkdir -p /kaniko/.docker | ||
| echo '{ | ||
| "auths": { | ||
| "${{ secrets.REGISTRY_URL }}": { | ||
| "username": "${{ secrets.REGISTRY_USERNAME }}", | ||
| "password": "${{ secrets.REGISTRY_PASSWORD }}" | ||
| } | ||
| } | ||
| }' > /kaniko/.docker/config.json | ||
|
|
||
| - name: Build and Push Docker Image | ||
| run: | | ||
| /kaniko/executor \ | ||
| --context . \ | ||
| --dockerfile ./Dockerfile \ | ||
| --destination ${{ secrets.REGISTRY_URL }}/my-app:${{ github.sha }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,4 +37,4 @@ yarn-error.log* | |
| next-env.d.ts | ||
|
|
||
| # jetBrains | ||
| .idea | ||
| .idea | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "files.associations": { | ||
| "*.yaml": "home-assistant" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| const nextJest = require('next/jest'); | ||
|
|
||
| const createJestConfig = nextJest({ | ||
| dir: './', | ||
| }); | ||
|
|
||
| const customJestConfig = { | ||
| setupFilesAfterEnv: ['<rootDir>/jest.setup.js'], | ||
| testEnvironment: 'jest-environment-jsdom', | ||
| moduleNameMapper: { | ||
| '^@/(.*)$': '<rootDir>/src/$1', | ||
| }, | ||
| }; | ||
|
|
||
| module.exports = createJestConfig(customJestConfig); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| import '@testing-library/jest-dom'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 10 months ago
To fix the issue, we need to explicitly define the permissions for the workflow and its jobs. Since the workflow primarily interacts with the repository contents (e.g., checking out code), the minimal required permission is
contents: read. This permission should be added at the root level of the workflow to apply to all jobs unless overridden. If specific jobs require additional permissions, they can define their ownpermissionsblock.