Skip to content

Commit

Permalink
Move repo level config from tackle2-ui (konveyor#15)
Browse files Browse the repository at this point in the history
Changes:
1. GH actions:
    -  PR template
    - on PR/push action with 2 jobs: standard prod build and extension 
       deployment using virtual screen
    -  nightly using the same jobs as PR/push action
2.  Add CI badges to main README
3. Add linting - rules inherited from VS Code generator and rules from
    tackle2-ui
4. Add OWNERS file
5. Fix test target - use separate build folder for webpack (out) and for
    tsc(test_out)
6. Set minimal node and npm versions - enforce them in GH actions via
    .nvmrc file
7. disable watch flag during webpack builds in prod mode
8. Fix linting errors detected by newly added linters

Reference-Url: https://github.com/konveyor/tackle2-ui/tree/release-0.5

---------

Signed-off-by: Radoslaw Szwajkowski <[email protected]>
  • Loading branch information
rszwajko authored Sep 25, 2024
1 parent 75c09a3 commit 2760043
Show file tree
Hide file tree
Showing 23 changed files with 2,305 additions and 173 deletions.
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
## PR Title Prefix
Every **PR Title** should be prefixed with :text: to indicate its type.
- Breaking change: :warning: (`:warning:`)
- Non-breaking feature: :sparkles: (`:sparkles:`)
- Patch fix: :bug: (`:bug:`)
- Docs: :book: (`:book:`)
- Infra/Tests/Other: :seedling: (`:seedling:`)
- No release note: :ghost: (`:ghost:`)
For example, a pull request containing breaking changes might look like
`:warning: My pull request contains breaking changes`.
Since GitHub supports emoji aliases (ie. `:ghost:`), there is no need to include
the emoji directly in the PR title -- **please use the alias**. It used to be
the case that projects using emojis for PR typing had to include the emoji
directly because GitHub didn't render the alias. Given that `:warning:` is
easy enough to read as text, easy to parse in release tooling, and rendered in
GitHub well, we prefer to standardize on the alias.
For more information, please see the Konveyor
[Versioning Doc](https://github.com/konveyor/release-tools/blob/main/VERSIONING.md).
-->
81 changes: 81 additions & 0 deletions .github/workflows/ci-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: CI (repo level)

on:
push:
branches:
- "main"
- "release-*"

pull_request:
branches:
- "main"
- "release-*"

workflow_dispatch:

workflow_call:

concurrency:
group: ci-repo-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true

jobs:
package-tests:
runs-on: ubuntu-latest

steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: "vscode/.nvmrc"

- name: Cache extension node_modules
uses: actions/cache@v3
with:
path: vscode/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('vscode/package-lock.json') }}

- name: Install dependencies
run: |
cd vscode
npm version
npm ci
- name: Lint sources
run: |
cd vscode
npm run lint
- name: Build
run: |
cd vscode
npm run package
vscode-tests:
runs-on: ubuntu-latest

steps:
- name: Check-out repository
uses: actions/checkout@v4

- name: Use Node.js from .nvmrc
uses: actions/setup-node@v4
with:
node-version-file: "vscode/.nvmrc"

- name: Cache extension node_modules
uses: actions/cache@v3
with:
path: vscode/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('vscode/package-lock.json') }}

- run: |
cd vscode
npm ci
- run: |
cd vscode
xvfb-run -a npm run test
11 changes: 11 additions & 0 deletions .github/workflows/nightly-ci-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Nightly CI (repo level @main)

on:
schedule:
- cron: "35 5 * * *" # every day @ 5:35am UTC

workflow_dispatch:

jobs:
nightly:
uses: ./.github/workflows/ci-repo.yml
16 changes: 16 additions & 0 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: PR Checks

on:
pull_request_target:
types: [opened, edited, reopened, synchronize]

jobs:
verify:
runs-on: ubuntu-latest
name: Verify PR contents
steps:
- name: Check Title
id: verifier
uses: konveyor/release-tools/cmd/verify-pr@main
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions OWNERS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Project Owners

This file specifies the code owners of the project.

## Our Maintainers

- David Zager ([djzager](https://github.com/djzager))
- Ian Bolton ([ibolton336](https://github.com/ibolton336))
- Scott Dickerson ([sjd78](https://github.com/sjd78))
- Radoslaw Szwajkowski ([rszwajko](https://github.com/rszwajko))
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Build and Test Status

| branch | last merge CI | nightly CI |
| :---------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| main | [![CI (repo level)](https://github.com/konveyor/editor-extensions/actions/workflows/ci-repo.yml/badge.svg?branch=main&event=push)](https://github.com/konveyor/editor-extensions/actions/workflows/ci-repo.yml) | [![CI (repo level)](https://github.com/konveyor/editor-extensions/actions/workflows/ci-repo.yml/badge.svg?branch=main&event=schedule)](https://github.com/konveyor/editor-extensions/actions/workflows/ci-repo.yml) |


# Konveyor Editor Extensions

This repository contains the assets and source code for editor extensions.
Expand Down
13 changes: 13 additions & 0 deletions vscode/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root=true

[*]
# standard prettier behaviors
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

# Configurable prettier behaviors
end_of_line = lf
indent_style = space
indent_size = 2
max_line_length = 100
1 change: 1 addition & 0 deletions vscode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
out
dist
node_modules
test_out
.vscode-test/
*.vsix
1 change: 1 addition & 0 deletions vscode/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.12.2
13 changes: 13 additions & 0 deletions vscode/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Library, IDE and build locations
**/node_modules/
**/coverage/
**/dist/
**/out/
.vscode/
.idea/
.eslintcache/

#
# NOTE: Could ignore anything that eslint will look at since eslint also applies
# prettier.
#
15 changes: 15 additions & 0 deletions vscode/.prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @type {import("prettier").Config} */
const config = {
// default value used
// trailingComma: "all",
// semi: true,
// singleQuote: false,

// Values used from .editorconfig:
// - printWidth == max_line_length
// - tabWidth == indent_size
// - useTabs == indent_style
// - endOfLine == end_of_line
};

export default config;
4 changes: 2 additions & 2 deletions vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@vscode/test-cli';
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: 'out/test/**/*.test.js',
files: "test_out/test/**/*.test.js",
});
95 changes: 79 additions & 16 deletions vscode/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,28 +1,91 @@
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import tsEslint from "typescript-eslint";
import prettierRecommended from "eslint-plugin-prettier/recommended";
import prettier from "eslint-plugin-prettier";
import unusedImports from "eslint-plugin-unused-imports";
import react from "eslint-plugin-react";
import globals from "globals";
import eslint from "@eslint/js";

export default [{
files: ["**/*.ts"],
}, {
export default [
eslint.configs.recommended,
...tsEslint.configs.recommended,
react.configs.flat.recommended,
prettierRecommended,
{
files: [
"**/*.js",
"**/*.jsx",
"**/*.cjs",
"**/*.mjs",
"**/*.ts",
"**/*.tsx",
],
},
{
plugins: {
"@typescript-eslint": typescriptEslint,
"@typescript-eslint": typescriptEslint,
prettier,
"unused-imports": unusedImports,
react,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 2022,
sourceType: "module",
parser: tsParser,
ecmaVersion: 2023, // keep in sync with tsconfig.json
sourceType: "module",
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
globals: {
...globals.es2023,
...globals.node,
myCustomGlobal: "readonly",
},
},

rules: {
"@typescript-eslint/naming-convention": ["warn", {
selector: "import",
format: ["camelCase", "PascalCase"],
}],
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "import",
format: ["camelCase", "PascalCase"],
},
],

curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
semi: "warn",
curly: "warn",
eqeqeq: "warn",
"no-throw-literal": "warn",
semi: "warn",

"prettier/prettier": ["warn"],
"@typescript-eslint/no-unused-vars": [
"warn",
{ argsIgnorePattern: "^_" },
],
"unused-imports/no-unused-imports": ["warn"],
"@typescript-eslint/no-explicit-any": "warn",
"react/jsx-key": "warn",
// "react-hooks/rules-of-hooks": "warn",
// "react-hooks/exhaustive-deps": "warn",
"no-extra-boolean-cast": "warn",
"prefer-const": "warn",
"react/no-unknown-property": ["warn"],
},

settings: {
react: { version: "detect" },
},
}];

ignores: [
// take the place of `.eslintignore`
"dist/",
"out/",
"generated/",
"node_modules/",
],
},
];
Loading

0 comments on commit 2760043

Please sign in to comment.