-
Notifications
You must be signed in to change notification settings - Fork 0
devops: add a workflow to verify git in container. #8
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
8 commits
Select commit
Hold shift + click to select a range
947f482
devops: add a workflow to verify git in container.
aslushnikov b0a95aa
fix
aslushnikov 343560f
ifx
aslushnikov c480a59
add proper tests
aslushnikov b1e5a6f
fix tests
aslushnikov 21cfc8c
fix
aslushnikov 4c1a4cb
chore: refactor tests
aslushnikov e8e5a70
fix tests
aslushnikov 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,30 @@ | ||
| name: Upload Flakiness.io report (fork PRs) | ||
| on: | ||
| workflow_run: | ||
| # Must match the name(s) of workflows that produce flakiness-report artifacts | ||
| workflows: ["Tests"] | ||
| types: [completed] | ||
|
|
||
| jobs: | ||
| upload-flakiness-report: | ||
| runs-on: ubuntu-latest | ||
| if: >- | ||
| (github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') | ||
| && github.event.workflow_run.event == 'pull_request' | ||
| && github.event.workflow_run.head_repository.full_name != github.event.workflow_run.repository.full_name | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Install Flakiness CLI | ||
| run: curl -LsSf https://cli.flakiness.io/install.sh | sh | ||
|
|
||
| - name: Download flakiness-report artifacts | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| RUN_ID: ${{ github.event.workflow_run.id }} | ||
| run: gh run download "$RUN_ID" --repo "$GITHUB_REPOSITORY" --pattern 'flakiness-report-*' --dir . | ||
|
|
||
| - name: Upload to Flakiness.io | ||
| run: find . -path '*/flakiness-report-*/report.json' -exec flakiness upload {} \; |
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: Tests | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
|
|
||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| test: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 24 | ||
|
|
||
| - name: Setup PNPM | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm i --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: pnpm exec playwright test | ||
|
|
||
| test-container: | ||
| runs-on: ubuntu-latest | ||
| container: node:24 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup PNPM | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10 | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm i --frozen-lockfile | ||
|
|
||
| - name: Run tests | ||
| run: pnpm exec playwright test | ||
| env: | ||
| FK_ENV_CONTAINER: '1' |
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
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
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,8 @@ | ||
| import { defineConfig } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './tests', | ||
| reporter: [ | ||
| ['@flakiness/playwright', { flakinessProject: 'flakiness/nodejs-sdk' }], | ||
| ], | ||
| }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { CIUtils } from '../src/ciUtils.js'; | ||
|
|
||
| const isGitHubActions = !!process.env.GITHUB_ACTIONS; | ||
|
|
||
| test.skip(!isGitHubActions, 'Only runs in GitHub Actions'); | ||
|
|
||
| test('runUrl() returns a valid GitHub Actions URL', () => { | ||
| const url = CIUtils.runUrl(); | ||
| expect(url).toBeTruthy(); | ||
| expect(url).toContain('/actions/runs/'); | ||
| expect(url).toContain(process.env.GITHUB_RUN_ID!); | ||
| // Verify it's a parseable URL | ||
| expect(() => new URL(url!)).not.toThrow(); | ||
| }); |
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 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { CPUUtilization } from '../src/cpuUtilization.js'; | ||
| import os from 'os'; | ||
|
|
||
| test('should work', async () => { | ||
| const cpu = new CPUUtilization(); | ||
| cpu.sample(); | ||
| await new Promise(x => setTimeout(x, 100)); | ||
| cpu.sample(); | ||
| const report: any = {}; | ||
| cpu.enrich(report); | ||
| expect(report.cpuCount).toBe(os.cpus().length); | ||
| expect(Array.isArray(report.cpuMax)).toBe(true); | ||
| expect(Array.isArray(report.cpuAvg)).toBe(true); | ||
| }); |
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,12 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { GithubOIDC } from '../src/githubOIDC.js'; | ||
|
|
||
| test.skip(!process.env.GITHUB_ACTIONS, 'Only runs in GitHub Actions'); | ||
| test.skip(!process.env.ACTIONS_ID_TOKEN_REQUEST_URL, 'Github OIDC not available — needs id-token: write permission'); | ||
|
|
||
| test('initializeFromEnv() mints a flakiness token in GitHub Actions with id-token:write', async () => { | ||
| const oidc = GithubOIDC.initializeFromEnv(); | ||
| expect(oidc).toBeTruthy(); | ||
| const token = await oidc!.createFlakinessAccessToken('flakiness/nodejs-sdk'); | ||
| expect(token).toBeTruthy(); | ||
| }); |
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,61 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { execSync } from 'child_process'; | ||
| import path from 'path'; | ||
| import { GitWorktree } from '../src/gitWorktree.js'; | ||
|
|
||
| test('GitWorktree.create() should work', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| expect(wt).toBeTruthy(); | ||
| expect(wt.rootPath()).toBeTruthy(); | ||
| }); | ||
|
|
||
| test('rootPath() returns an absolute path containing this repo', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const root = wt.rootPath(); | ||
| expect(path.isAbsolute(root)).toBe(true); | ||
| // The root should be an ancestor of the current working directory | ||
| expect(process.cwd().startsWith(path.normalize(root))).toBe(true); | ||
| }); | ||
|
|
||
| test('GitWorktree.headCommitId() returns a 40-char SHA', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const commitId = wt.headCommitId(); | ||
| expect(commitId).toMatch(/^[0-9a-f]{40}$/); | ||
| }); | ||
|
|
||
| test('GitWorktree.gitPath() converts absolute path to git-relative', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const gitPath = wt.gitPath(wt.rootPath() + '/package.json'); | ||
| expect(gitPath).toBe('package.json'); | ||
| }); | ||
|
|
||
| test('GitWorktree.gitPath() works for nested paths', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const gitPath = wt.gitPath(wt.rootPath() + '/src/gitWorktree.ts'); | ||
| expect(gitPath).toBe('src/gitWorktree.ts'); | ||
| }); | ||
|
|
||
| test('GitWorktree.absolutePath() converts git-relative to native absolute', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const absPath = wt.absolutePath('package.json'); | ||
| expect(absPath).toBe(path.join(wt.rootPath(), 'package.json')); | ||
| }); | ||
|
|
||
| test('GitWorktree.gitPath() and absolutePath() are inverses', () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const original = path.join(wt.rootPath(), 'src', 'gitWorktree.ts'); | ||
| const roundtripped = wt.absolutePath(wt.gitPath(original)); | ||
| expect(roundtripped).toBe(original); | ||
| }); | ||
|
|
||
| test('GitWorktree.listCommits() returns recent commits', async () => { | ||
| const wt = GitWorktree.create('.'); | ||
| const commits = await wt.listCommits(5); | ||
| expect(commits.length).toBe(5); | ||
| expect(commits[0].commitId).toMatch(/^[0-9a-f]{40}$/); | ||
| expect(commits[0].timestamp).toBeGreaterThan(0); | ||
| expect(commits[0].message).toBeTruthy(); | ||
| expect(commits[0].commitId).toBe(wt.headCommitId()); | ||
| }); | ||
|
|
||
|
|
||
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,14 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
| import { RAMUtilization } from '../src/ramUtilization.js'; | ||
| import os from 'os'; | ||
|
|
||
| test('should work', async () => { | ||
| const ram = new RAMUtilization(); | ||
| ram.sample(); | ||
| await new Promise(x => setTimeout(x, 100)); | ||
| ram.sample(); | ||
| const report: any = {}; | ||
| ram.enrich(report); | ||
| expect(report.ramBytes).toBe(os.totalmem()); | ||
| expect(Array.isArray(report.ram)).toBe(true); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.