Skip to content

Commit

Permalink
feat: added CI
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Nov 25, 2024
1 parent 8e959a7 commit 455cc1e
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 13,687 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Default CI
on:
push:
branches:
- main
pull_request:
branches:
- '**'
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Lint
run: npm run lint
10 changes: 10 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Run commitlint on the commit messages in a pull request.

name: Lint Commit Messages

on:
- pull_request

jobs:
commitlint:
uses: openedx/.github/.github/workflows/commitlint.yml@master
13 changes: 13 additions & 0 deletions .github/workflows/lockfileversion-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#check package-lock file version

name: Lockfile Version check

on:
push:
branches:
- main
pull_request:

jobs:
version-check:
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
1 change: 0 additions & 1 deletion config/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
console.log('============================= I AM RG ESLINT CONFIG =============================');
// eslint-disable-next-line import/no-extraneous-dependencies
const { createConfig } = require('@openedx/frontend-build');

Expand Down
1 change: 0 additions & 1 deletion config/.stylelintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
console.log('============================= I AM RG STYLELINT CONFIG =============================');
module.exports = {
extends: ["@edx/stylelint-config-edx"],
rules: {
Expand Down
2 changes: 1 addition & 1 deletion config/commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
rules: {
'type-enum':
[2, 'always', [
'revert', 'feat', 'fix', 'perf', 'docs', 'test', 'build', 'refactor', 'style', 'chore', 'temp',
'revert', 'feat', 'fix', 'perf', 'docs', 'test', 'build', 'refactor', 'style', 'chore', 'temp',
]],

// Default rules we want to suppress:
Expand Down
53 changes: 14 additions & 39 deletions lib/ConfigPreset.js
Original file line number Diff line number Diff line change
@@ -1,57 +1,32 @@
const path = require('path');
const resolveFilepaths = require('./resolveFilepaths');

const defaultConfigDir = path.resolve(__dirname, '../config');

/**
* Represents a configuration preset with methods to resolve default and custom configuration file paths.
* @typedef {Object} ConfigPresetOptions
* @property {string} [defaultDir] - The default directory to look for configuration files.
* Creates a configuration preset object with methods to access configuration files.
*
* @param {Object} options - Configuration options for the preset.
* @param {string} [options.defaultDir=defaultConfigDir] - The directory to search
* for the configuration file. Defaults to `../config`.
* @param {string} options.defaultFilename - The name of the default configuration file.
* @returns {Object} - An object representing the configuration preset.
* @property {string} defaultFilename - The name of the default configuration file.
* @property {string[]} searchFilenames - A list of filenames to search for.
* @property {string[]} searchFilepaths - A list of filepaths to search in.
*/

/**
* Creates a configuration preset object with methods to access and resolve configuration file paths.
* @param {ConfigPresetOptions} options - The options for creating the configuration preset.
* @returns {Object} Configuration preset with methods to get the default config and resolve custom paths.
* @property {string} defaultFilename - The name of the default configuration file.
* @property {Function} getDefault - Function to require the default configuration file.
* @property {string} defaultFilepath - Getter for the resolved path to the default configuration file.
* @property {string|null} resolvedFilepath - Getter for the resolved path of the first found configuration file.
* @property {Function} getDefault - A function that retrieves the default
* configuration object by resolving and requiring the configuration file.
*/
function ConfigPreset({
defaultDir = defaultConfigDir,
defaultFilename,
searchFilenames,
searchFilepaths,
}) {
return {
defaultFilename,
/**
* Gets the default configuration object by requiring the default file.
* @returns {any} The required default configuration object.
*/
* Retrieves the default configuration object by requiring the resolved configuration file.
*
* @returns {any} - The required default configuration object.
*/
// eslint-disable-next-line import/no-dynamic-require, global-require
getDefault: () => require(require.resolve(`./${defaultFilename}`, { paths: [defaultDir] })),
/**
* Resolves the full path of the default configuration file.
* @returns {string} The resolved path of the default configuration file.
*/
get defaultFilepath() {
console.log('getting default filepath', defaultFilename, defaultDir);
return require.resolve(`./${defaultFilename}`, { paths: [defaultDir] });
},
/**
* Resolves the first matching configuration file path from the provided filenames and filepaths.
* @returns {string|null} The resolved configuration file path or null if no file is found.
*/
get resolvedFilepath() {
return resolveFilepaths(
searchFilenames.map(filename => `./${filename}`),
[...searchFilepaths, defaultDir],
);
},
};
}

Expand Down
21 changes: 0 additions & 21 deletions lib/resolveFilepaths.js

This file was deleted.

Loading

0 comments on commit 455cc1e

Please sign in to comment.