Skip to content

Commit

Permalink
Adding prettier commands and prettier check to the lint workflow
Browse files Browse the repository at this point in the history
Also running the prettier command for the first time

Signed-off-by: ytimocin <[email protected]>
  • Loading branch information
ytimocin committed Oct 14, 2024
1 parent 38fcc3e commit ee342b6
Show file tree
Hide file tree
Showing 701 changed files with 8,173 additions and 8,765 deletions.
94 changes: 47 additions & 47 deletions .devcontainer/contributor/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
{
"name": "Radius - Contributor",
// For details see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
//Git and GitHub Setup
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
//Programming languages
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/guiyomh/features/gotestsum:0.1.1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/typescript:2": {},
"ghcr.io/devcontainers/features/python:1": {},
//Container and K8s
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"minikube": "none"
},
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"moby": true
},
//Tools
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/mpriscella/features/kind:1": {},
"ghcr.io/dhoeric/features/stern:1": {},
//Dapr
"ghcr.io/dapr/cli/dapr-cli:0": {}
"name": "Radius - Contributor",
// For details see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
//Git and GitHub Setup
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
//Programming languages
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/guiyomh/features/gotestsum:0.1.1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/typescript:2": {},
"ghcr.io/devcontainers/features/python:1": {},
//Container and K8s
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {
"minikube": "none"
},
"customizations": {
"vscode": {
"extensions": [
"redhat.vscode-yaml",
"golang.go",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-bicep",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-azuretools.vscode-dapr",
"ms-vscode.makefile-tools"
]
}
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest",
"moby": true
},
// Prerequisite for Code Generation, see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites#code-generation
// Adding workspace as safe directory to avoid permission issues
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/[email protected] && go install go.uber.org/mock/[email protected]",
"hostRequirements": {
"memory": "8gb"
},
}
//Tools
"ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {},
"ghcr.io/mpriscella/features/kind:1": {},
"ghcr.io/dhoeric/features/stern:1": {},
//Dapr
"ghcr.io/dapr/cli/dapr-cli:0": {}
},
"customizations": {
"vscode": {
"extensions": [
"redhat.vscode-yaml",
"golang.go",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-azuretools.vscode-bicep",
"ms-kubernetes-tools.vscode-kubernetes-tools",
"ms-azuretools.vscode-dapr",
"ms-vscode.makefile-tools"
]
}
},
// Prerequisite for Code Generation, see https://github.com/radius-project/radius/tree/main/docs/contributing/contributing-code/contributing-code-prerequisites#code-generation
// Adding workspace as safe directory to avoid permission issues
"postCreateCommand": "git config --global --add safe.directory /workspaces/radius && cd typespec && npm ci && npm install -g autorest && npm install -g oav && go install sigs.k8s.io/controller-tools/cmd/[email protected] && go install go.uber.org/mock/[email protected]",
"hostRequirements": {
"memory": "8gb"
}
}
87 changes: 48 additions & 39 deletions .github/scripts/radius-bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,44 @@ limitations under the License.
*/

module.exports = async ({ github, context }) => {
if (context.eventName === 'issue_comment' && context.payload.action === 'created') {
try {
await handleIssueCommentCreate({ github, context });
} catch (error) {
console.log(`[handleIssueCommentCreate] unexpected error: ${error}`);
}
if (
context.eventName === "issue_comment" &&
context.payload.action === "created"
) {
try {
await handleIssueCommentCreate({ github, context });
} catch (error) {
console.log(`[handleIssueCommentCreate] unexpected error: ${error}`);
}
}
}
};

// Handle issue comment create event.
async function handleIssueCommentCreate({ github, context }) {
const payload = context.payload;
const issue = context.issue;
const isFromPulls = !!payload.issue.pull_request;
const commentBody = payload.comment.body;
const username = context.actor;
const payload = context.payload;
const issue = context.issue;
const isFromPulls = !!payload.issue.pull_request;
const commentBody = payload.comment.body;
const username = context.actor;

if (!commentBody) {
console.log('[handleIssueCommentCreate] comment body not found, exiting.');
return;
}
if (!commentBody) {
console.log("[handleIssueCommentCreate] comment body not found, exiting.");
return;
}

const commandParts = commentBody.split(/\s+/);
const command = commandParts.shift();
const commandParts = commentBody.split(/\s+/);
const command = commandParts.shift();

switch (command) {
case '/assign':
await cmdAssign(github, issue, isFromPulls, username);
break;
default:
console.log(`[handleIssueCommentCreate] command ${command} not found, exiting.`);
break;
}
switch (command) {
case "/assign":
await cmdAssign(github, issue, isFromPulls, username);
break;
default:
console.log(
`[handleIssueCommentCreate] command ${command} not found, exiting.`,
);
break;
}
}

/**
Expand All @@ -58,18 +63,22 @@ async function handleIssueCommentCreate({ github, context }) {
* @param {*} username is the user who trigger the command
*/
async function cmdAssign(github, issue, isFromPulls, username) {
if (isFromPulls) {
console.log('[cmdAssign] pull requests not supported, skipping command execution.');
return;
} else if (issue.assignees && issue.assignees.length !== 0) {
console.log('[cmdAssign] issue already has assignees, skipping command execution.');
return;
}
if (isFromPulls) {
console.log(
"[cmdAssign] pull requests not supported, skipping command execution.",
);
return;
} else if (issue.assignees && issue.assignees.length !== 0) {
console.log(
"[cmdAssign] issue already has assignees, skipping command execution.",
);
return;
}

await github.rest.issues.addAssignees({
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
assignees: [username],
});
await github.rest.issues.addAssignees({
owner: issue.owner,
repo: issue.repo,
issue_number: issue.number,
assignees: [username],
});
}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: "18"
node-version: "22"
- name: Install TypeSpec compiler
run: |
pushd typespec
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/prettier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

name: Check code formatting is up-to-date

on:
pull_request:
branches:
- main
- release/*

concurrency:
group: prettier-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
prettier-check:
name: Prettier
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup NodeJS
uses: actions/setup-node@v4
with:
node-version: "22"
- name: Run `make prettier-check`
id: prettier-check
run: |
make prettier-check
- name: Check for Prettier failures
if: steps.prettier-check.outcome == 'failure'
run: |
echo "Prettier check failed. Please fix the formatting issues."
exit 1
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# .prettierignore
pkg/validator/testdata/put-environments-invalid-json.json

hack/bicep-types-radius/generated/*

bicep-types/*
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Contributing

Radius is in an early phase of development right now. We welcome feedback in the form of issues that comes from usage and is aligned with the current scope and goals of the project.
Radius is in an early phase of development right now. We welcome feedback in the form of issues that comes from usage and is aligned with the current scope and goals of the project.

## Table of contents

You can find our full **contributor documentation** including instructions at the following links:

- [How to contribute](./docs/contributing/how-to.md)
- [See "good first issues"](https://github.com/radius-project/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22)
- [See "good first issues"](https://github.com/radius-project/radius/issues?q=is:issue+is:open+label:%22good+first+issue%22)
- [Install prerequisites](./docs/contributing/contributing-code/contributing-code-prerequisites/)
- [Create your first commit (full walkthrough)](./docs/contributing/contributing-code/contributing-code-first-commit/)
- [Building the repo](./docs/contributing/contributing-code/contributing-code-building/)
Expand All @@ -21,7 +21,7 @@ You can find our full **contributor documentation** including instructions at th

We welcome small pull request contributions from anyone (docs improvements, bug fixes, minor features.) as long as they follow a few guidelines:

- For very minor changes like correcting a typo feel free to send a pull request. Otherwise ...
- For very minor changes like correcting a typo feel free to send a pull request. Otherwise ...
- Please start by [choosing an existing issue](https://github.com/radius-project/radius/issues), or [opening an issue](https://github.com/radius-project/radius/issues/new/choose) to work on.
- The maintainers will respond to your issue, please work with the maintainers to ensure that what you're doing is in scope for the project before writing any code.
- If you have any doubt whether a contribution would be valuable, feel free to ask.
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
ARROW := \033[34;1m=>\033[0m

# order matters for these
include build/help.mk build/version.mk build/build.mk build/util.mk build/generate.mk build/test.mk build/docker.mk build/recipes.mk build/install.mk build/db.mk build/debug.mk
include build/help.mk build/version.mk build/build.mk build/util.mk build/generate.mk build/test.mk build/docker.mk build/recipes.mk build/install.mk build/db.mk build/debug.mk build/prettier.mk
31 changes: 31 additions & 0 deletions build/prettier.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

.PHONY: prettier-check prettier-format me prettier

PRETTIER_VERSION := 3.3.3

prettier-check:
@npx prettier@$(PRETTIER_VERSION) --check "*/**/*.{ts,js,mjs,json}"

prettier-format:
@npx prettier@$(PRETTIER_VERSION) --write "*/**/*.{ts,js,mjs,json}"

me:
@echo "🪄💄🪄💄🪄💄"

prettier:
@npx prettier@$(PRETTIER_VERSION) --write "*/**/*.{ts,js,mjs,json}"
35 changes: 16 additions & 19 deletions deploy/devcontainer-feature/src/radcli/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
{
"name": "Radius CLI",
"id": "radcli",
"version": "0.1.0",
"dependsOn": {
"ghcr.io/dhoeric/features/oras:1": {}
},
"description": "Installs the Radius CLI along with needed dependencies.",
"documentationURL": "https://docs.radapp.io/installation/",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"edge"
],
"default": "latest",
"description": "Select or enter an Radius CLI version. Use 'latest' for the latest stable version, 'edge' for the latest development version, or a specific version number (e.g. 0.28.0)."
}
"name": "Radius CLI",
"id": "radcli",
"version": "0.1.0",
"dependsOn": {
"ghcr.io/dhoeric/features/oras:1": {}
},
"description": "Installs the Radius CLI along with needed dependencies.",
"documentationURL": "https://docs.radapp.io/installation/",
"options": {
"version": {
"type": "string",
"proposals": ["latest", "edge"],
"default": "latest",
"description": "Select or enter an Radius CLI version. Use 'latest' for the latest stable version, 'edge' for the latest development version, or a specific version number (e.g. 0.28.0)."
}
}
}
}
Loading

0 comments on commit ee342b6

Please sign in to comment.