Skip to content

Commit 80dc4ee

Browse files
authored
feat: Add ability to use GitHub OIDC (#161)
Add GH OIDC functionality to the plugin core, enabling it in all of the other plugins.
1 parent be89828 commit 80dc4ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+969
-65
lines changed

.changeset/lucky-seals-admire.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@codecov/nextjs-webpack-plugin": minor
3+
"@codecov/bundler-plugin-core": minor
4+
"@codecov/remix-vite-plugin": minor
5+
"@codecov/solidstart-plugin": minor
6+
"@codecov/sveltekit-plugin": minor
7+
"@codecov/webpack-plugin": minor
8+
"@codecov/rollup-plugin": minor
9+
"@codecov/nuxt-plugin": minor
10+
"@codecov/vite-plugin": minor
11+
---
12+
13+
Add the ability for users to use GH OIDC instead of explicit upload tokens

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1212
cancel-in-progress: true
1313

14+
permissions:
15+
id-token: write
16+
1417
jobs:
1518
install:
1619
name: Install deps
@@ -284,6 +287,7 @@ jobs:
284287
"next-js",
285288
"next-js-15",
286289
"nuxt",
290+
"oidc",
287291
"remix",
288292
"rollup",
289293
"sveltekit",
@@ -343,6 +347,7 @@ jobs:
343347
NEXT_API_URL: ${{ secrets.CODECOV_API_URL }}
344348
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
345349
NUXT_API_URL: ${{ secrets.CODECOV_API_URL }}
350+
OIDC_API_URL: ${{ secrets.CODECOV_API_URL }}
346351
REMIX_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
347352
REMIX_API_URL: ${{ secrets.CODECOV_API_URL }}
348353
ROLLUP_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
@@ -371,6 +376,7 @@ jobs:
371376
"next-js",
372377
"next-js-15",
373378
"nuxt",
379+
"oidc",
374380
"remix",
375381
"rollup",
376382
"sveltekit",
@@ -430,6 +436,7 @@ jobs:
430436
NEXT_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
431437
NUXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
432438
NUXT_API_URL: ${{ secrets.CODECOV_API_URL }}
439+
OIDC_API_URL: ${{ secrets.CODECOV_API_URL }}
433440
REMIX_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
434441
REMIX_API_URL: ${{ secrets.CODECOV_API_URL }}
435442
ROLLUP_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}

examples/oidc/.eslintrc.cjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
root: true,
3+
env: { browser: true, es2020: true },
4+
extends: [
5+
'eslint:recommended',
6+
'plugin:@typescript-eslint/recommended',
7+
'plugin:react-hooks/recommended',
8+
],
9+
ignorePatterns: ['dist', '.eslintrc.cjs'],
10+
parser: '@typescript-eslint/parser',
11+
plugins: ['react-refresh'],
12+
rules: {
13+
'react-refresh/only-export-components': [
14+
'warn',
15+
{ allowConstantExport: true },
16+
],
17+
},
18+
}

examples/oidc/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

examples/oidc/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# React + TypeScript + Vite
2+
3+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4+
5+
Currently, two official plugins are available:
6+
7+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9+
10+
## Expanding the ESLint configuration
11+
12+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13+
14+
- Configure the top-level `parserOptions` property like this:
15+
16+
```js
17+
parserOptions: {
18+
ecmaVersion: 'latest',
19+
sourceType: 'module',
20+
project: ['./tsconfig.json', './tsconfig.node.json'],
21+
tsconfigRootDir: __dirname,
22+
},
23+
```
24+
25+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
26+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
27+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list

examples/oidc/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React + TS</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.tsx"></script>
12+
</body>
13+
</html>

examples/oidc/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@codecov/example-oidc-app",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "tsc && vite build",
9+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"react": "^18.2.0",
14+
"react-dom": "^18.2.0"
15+
},
16+
"devDependencies": {
17+
"@codecov/vite-plugin": "workspace:^",
18+
"@types/react": "^18.2.51",
19+
"@types/react-dom": "^18.2.18",
20+
"@typescript-eslint/eslint-plugin": "^6.20.0",
21+
"@typescript-eslint/parser": "^6.20.0",
22+
"@vitejs/plugin-react": "^4.2.1",
23+
"eslint": "^8.56.0",
24+
"eslint-plugin-react-hooks": "^4.6.0",
25+
"eslint-plugin-react-refresh": "^0.4.5",
26+
"rollup": "^4.9.6",
27+
"typescript": "^5.3.3",
28+
"vite": "^5.2.10"
29+
},
30+
"volta": {
31+
"extends": "../../package.json"
32+
},
33+
"engines": {
34+
"node": ">=18.0.0"
35+
}
36+
}

examples/oidc/public/vite.svg

Lines changed: 1 addition & 0 deletions
Loading

examples/oidc/src/App.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#root {
2+
max-width: 1280px;
3+
margin: 0 auto;
4+
padding: 2rem;
5+
text-align: center;
6+
}
7+
8+
.logo {
9+
height: 6em;
10+
padding: 1.5em;
11+
will-change: filter;
12+
transition: filter 300ms;
13+
}
14+
.logo:hover {
15+
filter: drop-shadow(0 0 2em #646cffaa);
16+
}
17+
.logo.react:hover {
18+
filter: drop-shadow(0 0 2em #61dafbaa);
19+
}
20+
21+
@keyframes logo-spin {
22+
from {
23+
transform: rotate(0deg);
24+
}
25+
to {
26+
transform: rotate(360deg);
27+
}
28+
}
29+
30+
@media (prefers-reduced-motion: no-preference) {
31+
a:nth-of-type(2) .logo {
32+
animation: logo-spin infinite 20s linear;
33+
}
34+
}
35+
36+
.card {
37+
padding: 2em;
38+
}
39+
40+
.read-the-docs {
41+
color: #888;
42+
}

examples/oidc/src/App.tsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { useState, lazy, Suspense } from "react";
2+
import reactLogo from "./assets/react.svg";
3+
import viteLogo from "/vite.svg";
4+
import "./App.css";
5+
6+
const IndexedLazyComponent = lazy(() => import("./IndexedLazyComponent"));
7+
const LazyComponent = lazy(() => import("./LazyComponent/LazyComponent"));
8+
9+
function App() {
10+
const [count, setCount] = useState(0);
11+
12+
return (
13+
<>
14+
<div>
15+
<a href="https://vitejs.dev" target="_blank">
16+
<img src={viteLogo} className="logo" alt="Vite logo" />
17+
</a>
18+
<a href="https://react.dev" target="_blank">
19+
<img src={reactLogo} className="logo react" alt="React logo" />
20+
</a>
21+
</div>
22+
<h1>Vite + React</h1>
23+
<div className="card">
24+
<button onClick={() => setCount((count) => count + 1)}>
25+
count is {count}
26+
</button>
27+
<p>
28+
Edit <code>src/App.tsx</code> and save to test HMR
29+
</p>
30+
</div>
31+
<p className="read-the-docs">
32+
Click on the Vite and React logos to learn more
33+
</p>
34+
<Suspense fallback={null}>
35+
<IndexedLazyComponent />
36+
</Suspense>
37+
<Suspense fallback={null}>
38+
<LazyComponent />
39+
</Suspense>
40+
</>
41+
);
42+
}
43+
44+
export default App;

0 commit comments

Comments
 (0)