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

[code-infra] Fix deploy #212

Merged
merged 10 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.cache
/.git
/contributor-dashboard-legacy/
/tools-public/toolpad/.generated/
/tools-public/toolpad/**/*.yml
build
node_modules
pnpm-lock.yaml
Comment on lines 1 to 7
Copy link
Member Author

Choose a reason for hiding this comment

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

Get to lint this a bit more.

6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,11 @@ module.exports = {
},
overrides: [
...baseline.overrides,
{
files: ['contributor-dashboard-legacy/**'],
rules: {
'import/no-unresolved': 'off', // TODO, to fix at one point
Copy link
Member Author

Choose a reason for hiding this comment

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

This is because we are not using the pnpm workspace for contributor-dashboard-legacy.

One thing that I didn't try is to simply add contributor-dashboard-legacy in the pnpm workspace. Maybe one day in the future.

},
},
],
};
20 changes: 1 addition & 19 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@

# dependencies
node_modules
/.pnp
.pnp.js

# testing
/.env
/.eslintcache
/coverage

# production
/build

src
Copy link
Member Author

Choose a reason for hiding this comment

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

That was crazy.


# misc
.DS_Store
.env.local
Expand All @@ -33,27 +28,14 @@ yarn-error.log*
.netlify

# local env files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# docs

/docs/export

lerna-debug.log

.env

dist/

packages/toolpad-app/public/web_modules
packages/toolpad-app/public/runtime
packages/toolpad-app/public/reactDevtools
packages/toolpad-app/public/runtime
packages/toolpad-app/public/typings.json
packages/toolpad-app/prisma/generated


.toolpad-generated
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
/tools-public/toolpad/**/*.yml
/tools-public/toolpad/.generated/
Comment on lines -1 to -2
Copy link
Member Author

Choose a reason for hiding this comment

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

Match mui-private

1 change: 1 addition & 0 deletions contributor-dashboard-legacy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Bugfixes and feature suggestions are greatly appreciated. Though this project is
Copy `.env.example` to `.env` and fill in the values as instructed in the file.

```bash
$ pnpm --ignore-workspace install
$ npx netlify login
$ npx netlify dev
```
42 changes: 42 additions & 0 deletions contributor-dashboard-legacy/functions/circle-ci-artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
async function fetchCircleCIApiV2(endpoint) {
const url = `https://circleci.com/api/v2/${endpoint}`;

// eslint-disable-next-line no-console
console.log(url);
const response = await fetch(url);
const json = await response.json();
return json;
}

/**
* netlify function that wraps CircleCI API v2 which requires authentification.
*
* @param {*} event
* @param {*} context
*/
exports.handler = async function circleCIArtefact(event) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Bypass CORS after CircleCI API change.

Copy link
Member

Choose a reason for hiding this comment

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

Do I understand correctly that to fill the table we're fetching from multiple functions and reconcile them client-side?
It feels somewhat wasteful to me, especially since some of the functions seem to do cache control and others don't. Isn't it more logical to fetch and reconcile data in a single netlify function, add cache control and serve it in a format that can easily be fed into a table?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree

Copy link
Member

Choose a reason for hiding this comment

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

🤔 Actually, we're already calculating the diff in the dangerfile. Would probably make more sense to just calculate the diff in CI, store it on file and push it to S3 and make it public. Then danger can just read the file and the UI/toolpad can fetch from S3. We wouldn't have to fetch and calculate in 3 places and we wouldn't have the problem with disappearing expired build artifacts neither.

Not for this PR though.

const { queryStringParameters } = event;

const buildNumberParameter = queryStringParameters.buildNumber;
const buildNumber = parseInt(buildNumberParameter, 10);
if (Number.isNaN(buildNumber)) {
return {
statusCode: 500,
body: JSON.stringify(
`Given query param buildNumber is not a number. Received '${buildNumberParameter}'.`,
),
};
}
// eslint-disable-next-line no-console
console.log(`fetching details for job #${buildNumber}`);

const artifacts = await fetchCircleCIApiV2(
`project/github/mui/material-ui/${buildNumber}/artifacts`,
);
const response = {
statusCode: 200,
body: JSON.stringify(artifacts),
};

return response;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const crypto = require("crypto");
const zlib = require("zlib");
const fetch = require("node-fetch");
const { URL } = require("url");
const util = require("util");

Expand Down Expand Up @@ -42,7 +41,7 @@ function computeEtag(context) {
*/
exports.handler = async function fetchTestProfileArtifactHandler(
event,
context
context,
) {
const { queryStringParameters } = event;

Expand All @@ -54,7 +53,7 @@ exports.handler = async function fetchTestProfileArtifactHandler(
return {
statusCode: 500,
body: JSON.stringify(
`Given query param \`url\` is not a valid URL. Received '${urlParameter}'.`
`Given query param \`url\` is not a valid URL. Received '${urlParameter}'.`,
),
};
}
Expand Down Expand Up @@ -88,7 +87,7 @@ exports.handler = async function fetchTestProfileArtifactHandler(
return {
statusCode: 500,
body: JSON.stringify(
`Unable to get CircleCI response for '${url}' that is OK. Got ${testProfileArtifactResponse.status}`
`Unable to get CircleCI response for '${url}' that is OK. Got ${testProfileArtifactResponse.status}`,
),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const fetch = require("node-fetch");

/**
* Whether we sent Cache-Control headers.
* Can't send them from netlify due to https://community.netlify.com/t/netlify-function-responds-with-wrong-body/27138
Expand Down Expand Up @@ -76,7 +74,7 @@ exports.handler = async function fetchTestProfileDetails(event) {
return {
statusCode: 500,
body: JSON.stringify(
`Given query param jobNumber is not a number. Received '${jobNumberParameter}'.`
`Given query param jobNumber is not a number. Received '${jobNumberParameter}'.`,
),
};
}
Expand Down
17 changes: 16 additions & 1 deletion contributor-dashboard-legacy/netlify.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
[build]
functions = "functions"
base = "contributor-dashboard-legacy"

# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "build"

# Default build command.
command = "pnpm build"

[build.environment]
NODE_VERSION = "18"
PNPM_FLAGS = "--ignore-workspace"

[functions]
directory = "functions"
24 changes: 11 additions & 13 deletions contributor-dashboard-legacy/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "mui-maintainer-dashboard",
"name": "contributor-dashboard-legacy",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.1.2",
"@emotion/styled": "^11.0.0",
"@material-ui/core": "^5.0.0-alpha.19",
"@material-ui/icons": "^5.0.0-alpha.19",
"@mui/icons-material": "^6.0.0",
"@mui/material": "^6.0.0",
"pretty-bytes": "^5.3.0",
"react": "experimental",
"react-dom": "experimental",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-query": "^2.0.0",
"react-router": "^6.0.0-alpha.5",
"react-router-dom": "^6.0.0-alpha.5"
Expand All @@ -20,14 +20,12 @@
"@types/react-dom": "^17.0.0",
"@types/react-router-dom": "^5.1.3",
"netlify-cli": "^2.69.0",
"node-fetch": "^2.6.1",
"prettier": "^2.0.2",
"react-scripts": "^4.0.3",
"react-scripts": "^5.0.0",
"typescript": "^4.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",
"start": "NODE_OPTIONS=--openssl-legacy-provider DISABLE_ESLINT_PLUGIN=true SKIP_PREFLIGHT_CHECK=true react-scripts start",
"build": "NODE_OPTIONS=--openssl-legacy-provider DISABLE_ESLINT_PLUGIN=true SKIP_PREFLIGHT_CHECK=true react-scripts build",
"format": "prettier --write .",
"format:check": "prettier --check .",
"test": "echo 'No tests yet' && exit 1",
Expand All @@ -49,7 +47,7 @@
"last 1 safari version"
]
},
"engines": {
"node": "^16.0.0"
}
"engines": {
"node": ">=18.0.0"
}
}
Loading
Loading