Skip to content
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

chore: Remove requirements for upload tokens #153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
716a83c
remove NoUploadTokenError
nicholas-codecov Aug 8, 2024
c371e9c
update getPreSignedURL to remove requirement for uploadToken
nicholas-codecov Aug 8, 2024
5f087a3
update Output tests
nicholas-codecov Aug 8, 2024
eac3ca3
add in changeset
nicholas-codecov Aug 8, 2024
1903a8e
allow users to override git service for tokenless uploads
nicholas-codecov Aug 9, 2024
ac5526c
update types with gitService
nicholas-codecov Aug 9, 2024
9b1f678
add back no upload token error and new undefined git service error
nicholas-codecov Aug 9, 2024
1edaf90
add in new function used to find the origin git service
nicholas-codecov Aug 9, 2024
4ecd466
update getPreSignedURL to support tokenless uploads
nicholas-codecov Aug 9, 2024
d63d4f4
actually use the passed git service
nicholas-codecov Aug 9, 2024
20ddadc
apply feedback
nicholas-codecov Aug 19, 2024
06ff6bd
add tokenless examples to readme's
nicholas-codecov Aug 19, 2024
0e971a2
adjust docstring value
nicholas-codecov Aug 20, 2024
dac7bca
update doc string examples
nicholas-codecov Aug 21, 2024
6f0a7d3
update readme examples
nicholas-codecov Aug 21, 2024
e7e7888
more docstring updates
nicholas-codecov Aug 21, 2024
4221ae8
update readme copy
nicholas-codecov Aug 26, 2024
8185ae8
add in tokenless example
nicholas-codecov Aug 26, 2024
388df7a
forgot to add to ci
nicholas-codecov Aug 26, 2024
724ef8f
add nextjs to changeset
nicholas-codecov Aug 26, 2024
189178c
update nextjs readme
nicholas-codecov Aug 26, 2024
e1a60d8
update github actions to override the branch value if from a forked PR
nicholas-codecov Aug 27, 2024
e1ff1aa
remove tokenless example, as it only works with forks
nicholas-codecov Aug 27, 2024
7ca44df
update readme with new examples
nicholas-codecov Aug 27, 2024
bf510dd
add in tokenless example
nicholas-codecov Aug 27, 2024
ca6b771
add git service to other examples
nicholas-codecov Aug 27, 2024
eddd2ab
small typo fix
nicholas-codecov Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/kind-camels-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@codecov/nextjs-webpack-plugin": minor
"@codecov/bundler-plugin-core": patch
"@codecov/nuxt-plugin": patch
"@codecov/remix-vite-plugin": patch
"@codecov/rollup-plugin": patch
"@codecov/solidstart-plugin": patch
"@codecov/sveltekit-plugin": patch
"@codecov/vite-plugin": patch
"@codecov/webpack-plugin": patch
---

Remove requirement for uploadToken being present adding support for tokenless uploads.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: We need to update the README of the packages as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrrm trying to think of a nice way to word "this", do you think having two examples or just adjusting the current codeblock to have the same options but just commenting around the differences would be better?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make tokenless the default snippet, and then add an extra section below about what to do if you need to use the token, but keep that at the bottom.

6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ jobs:
"vite",
"webpack",
"solidstart",
"tokenless",
]
steps:
- name: Checkout
Expand Down Expand Up @@ -352,6 +353,8 @@ jobs:
SVELTEKIT_API_URL: ${{ secrets.CODECOV_API_URL }}
VITE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
VITE_API_URL: ${{ secrets.CODECOV_API_URL }}
TOKENLESS_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
TOKENLESS_API_URL: ${{ secrets.CODECOV_API_URL }}
WEBPACK_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
WEBPACK_API_URL: ${{ secrets.CODECOV_API_URL }}
run: pnpm run build
Expand All @@ -374,6 +377,7 @@ jobs:
"vite",
"webpack",
"solidstart",
"tokenless",
]
steps:
- name: Checkout
Expand Down Expand Up @@ -436,6 +440,8 @@ jobs:
SVELTEKIT_API_URL: ${{ secrets.CODECOV_API_URL }}
VITE_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
VITE_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
TOKENLESS_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
TOKENLESS_API_URL: ${{ secrets.CODECOV_API_URL }}
WEBPACK_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
WEBPACK_API_URL: ${{ secrets.CODECOV_STAGING_API_URL }}
run: pnpm run build
Expand Down
1 change: 1 addition & 0 deletions examples/next-js-15/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const nextConfig = {
uploadToken: process.env.NEXT_UPLOAD_TOKEN,
apiUrl: process.env.NEXT_API_URL,
webpack: options.webpack,
gitService: "github",
debug: true,
}),
);
Expand Down
1 change: 1 addition & 0 deletions examples/next-js/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
uploadToken: process.env.NEXT_UPLOAD_TOKEN,
apiUrl: process.env.NEXT_API_URL,
webpack: options.webpack,
gitService: "github",
debug: true,
}),
);
Expand Down
1 change: 1 addition & 0 deletions examples/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default defineNuxtConfig({
bundleName: "@codecov/example-nuxt-app",
uploadToken: process.env.NUXT_UPLOAD_TOKEN,
apiUrl: process.env.NUXT_API_URL,
gitService: "github",
debug: true,
},
],
Expand Down
1 change: 1 addition & 0 deletions examples/remix/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default defineConfig({
bundleName: "@codecov/example-remix-app",
uploadToken: process.env.REMIX_UPLOAD_TOKEN,
apiUrl: process.env.REMIX_API_URL,
gitService: "github",
debug: true,
}),
],
Expand Down
1 change: 1 addition & 0 deletions examples/rollup/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default defineConfig({
bundleName: "@codecov/example-rollup-app",
apiUrl: process.env.ROLLUP_API_URL,
uploadToken: process.env.ROLLUP_UPLOAD_TOKEN,
gitService: "github",
debug: true,
uploadOverrides: {
sha: process.env.HEAD_SHA,
Expand Down
3 changes: 2 additions & 1 deletion examples/solidstart/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export default defineConfig({
bundleName: "@codecov/example-solidstart-app",
uploadToken: process.env.SOLIDSTART_UPLOAD_TOKEN,
apiUrl: process.env.SOLIDSTART_API_URL,
gitService: "github",
debug: true,
}) as any,
}),
],
},
});
1 change: 1 addition & 0 deletions examples/sveltekit/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default defineConfig({
bundleName: "@codecov/example-sveltekit-app",
uploadToken: process.env.SVELTEKIT_UPLOAD_TOKEN,
apiUrl: process.env.SVELTEKIT_API_URL,
gitService: "github",
debug: true,
}),
],
Expand Down
18 changes: 18 additions & 0 deletions examples/tokenless/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions examples/tokenless/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
27 changes: 27 additions & 0 deletions examples/tokenless/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@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
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
```

- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
- 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
13 changes: 13 additions & 0 deletions examples/tokenless/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
36 changes: 36 additions & 0 deletions examples/tokenless/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "@codecov/example-tokenless-app",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@codecov/vite-plugin": "workspace:^",
"@types/react": "^18.2.51",
"@types/react-dom": "^18.2.18",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"rollup": "^4.9.6",
"typescript": "^5.3.3",
"vite": "^5.2.10"
},
"volta": {
"extends": "../../package.json"
},
"engines": {
"node": ">=18.0.0"
}
}
1 change: 1 addition & 0 deletions examples/tokenless/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions examples/tokenless/src/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.react:hover {
filter: drop-shadow(0 0 2em #61dafbaa);
}

@keyframes logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

@media (prefers-reduced-motion: no-preference) {
a:nth-of-type(2) .logo {
animation: logo-spin infinite 20s linear;
}
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}
44 changes: 44 additions & 0 deletions examples/tokenless/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { useState, lazy, Suspense } from "react";
import reactLogo from "./assets/react.svg";
import viteLogo from "/vite.svg";
import "./App.css";

const IndexedLazyComponent = lazy(() => import("./IndexedLazyComponent"));
const LazyComponent = lazy(() => import("./LazyComponent/LazyComponent"));

function App() {
const [count, setCount] = useState(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<Suspense fallback={null}>
<IndexedLazyComponent />
</Suspense>
<Suspense fallback={null}>
<LazyComponent />
</Suspense>
</>
);
}

export default App;
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function IndexedLazyComponent() {
return (
<div>
<h1>Indexed Lazy Component</h1>
</div>
);
}
1 change: 1 addition & 0 deletions examples/tokenless/src/IndexedLazyComponent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./IndexedLazyComponent";
14 changes: 14 additions & 0 deletions examples/tokenless/src/LazyComponent/LazyComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { lazy, Suspense } from "react";

const IndexedLazyComponent = lazy(() => import("../IndexedLazyComponent"));

export default function LazyComponent() {
return (
<div>
<h1>Lazy Component</h1>
<Suspense fallback={null}>
<IndexedLazyComponent />
</Suspense>
</div>
);
}
1 change: 1 addition & 0 deletions examples/tokenless/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading