feat(CI): Add Continuous Integration workflows for Gitea with Docker-based setup

This commit is contained in:
Philipp Kunz 2025-01-29 18:00:43 +01:00
parent b46fb0f042
commit 2d1c037301
14 changed files with 250 additions and 44 deletions

View File

@ -0,0 +1,66 @@
name: Default (not tags)
on:
push:
tags-ignore:
- '**'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Install pnpm and npmci
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
- name: Run npm prepare
run: npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build

View File

@ -0,0 +1,124 @@
name: Default (tags)
on:
push:
tags:
- '*'
env:
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
jobs:
security:
runs-on: ubuntu-latest
continue-on-error: true
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Audit production dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --prod
continue-on-error: true
- name: Audit development dependencies
run: |
npmci command npm config set registry https://registry.npmjs.org
npmci command pnpm audit --audit-level=high --dev
continue-on-error: true
test:
if: ${{ always() }}
needs: security
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Test stable
run: |
npmci node install stable
npmci npm install
npmci npm test
- name: Test build
run: |
npmci node install stable
npmci npm install
npmci npm build
release:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Release
run: |
npmci node install stable
npmci npm publish
metadata:
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
container:
image: ${{ env.IMAGE }}
continue-on-error: true
steps:
- uses: actions/checkout@v3
- name: Prepare
run: |
pnpm install -g pnpm
pnpm install -g @ship.zone/npmci
npmci npm prepare
- name: Code quality
run: |
npmci command npm install -g typescript
npmci npm install
- name: Trigger
run: npmci trigger
- name: Build docs and upload artifacts
run: |
npmci node install stable
npmci npm install
pnpm install -g @git.zone/tsdoc
npmci command tsdoc
continue-on-error: true

3
.gitignore vendored
View File

@ -3,7 +3,6 @@
# artifacts # artifacts
coverage/ coverage/
public/ public/
pages/
# installs # installs
node_modules/ node_modules/
@ -17,4 +16,4 @@ node_modules/
dist/ dist/
dist_*/ dist_*/
# custom #------# custom

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## 2025-01-29 - 2.1.0 - feat(CI)
Add Continuous Integration workflows for Gitea with Docker-based setup
- Added new CI workflows for handling both regular and tagged pushes in Gitea.
- Integrated security audits and setup tasks using Docker images in the CI workflows.
- Ensured that CI includes testing, building, and releasing steps as per tag events.
## 2025-01-29 - 2.0.39 - fix(package.json) ## 2025-01-29 - 2.0.39 - fix(package.json)
Add pnpm overrides configuration for peek-readable package Add pnpm overrides configuration for peek-readable package

View File

@ -6,8 +6,8 @@
"gitzone": { "gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "code.foss.global",
"gitscope": "gitzone", "gitscope": "git.zone",
"gitrepo": "tswatch", "gitrepo": "tswatch",
"shortDescription": "watch typescript projects during development", "shortDescription": "watch typescript projects during development",
"npmPackagename": "@git.zone/tswatch", "npmPackagename": "@git.zone/tswatch",

View File

@ -13,7 +13,8 @@
}, },
"scripts": { "scripts": {
"test": "(tstest test/ --web)", "test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)" "build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.2.1", "@git.zone/tsbuild": "^2.2.1",
@ -72,9 +73,15 @@
"node.js", "node.js",
"development server" "development server"
], ],
"repository": {
"type": "git",
"url": "https://code.foss.global/git.zone/tswatch.git"
},
"bugs": {
"url": "https://code.foss.global/git.zone/tswatch/issues"
},
"homepage": "https://code.foss.global/git.zone/tswatch#readme",
"pnpm": { "pnpm": {
"overrides": { "overrides": {}
"peek-readable": "5.3.1"
}
} }
} }

View File

@ -1,4 +1,5 @@
# @git.zone/tswatch # @git.zone/tswatch
A development tool for watching and re-compiling TypeScript projects automatically upon detecting changes. A development tool for watching and re-compiling TypeScript projects automatically upon detecting changes.
## Install ## Install
@ -141,9 +142,9 @@ import { TsWatch } from '@git.zone/tswatch';
const setupMultipleWatchers = async () => { const setupMultipleWatchers = async () => {
const tsWatchInstance = new TsWatch('node'); const tsWatchInstance = new TsWatch('node');
// View active watchers through instance mapping // View active watchers through instance mapping
tsWatchInstance.watcherMap.forEach(watcher => { tsWatchInstance.watcherMap.forEach((watcher) => {
console.log(`Watcher listening on: ${watcher.toString()}`); console.log(`Watcher listening on: ${watcher.toString()}`);
}); });
@ -180,7 +181,7 @@ Explore the various features and tailor the tool to fit your unique project requ
## License and Legal Information ## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. **Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tswatch', name: '@git.zone/tswatch',
version: '2.0.39', version: '2.1.0',
description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.' description: 'A development tool for automatically watching and re-compiling TypeScript projects upon detecting file changes, enhancing developer workflows.'
} }

View File

@ -1,7 +1 @@
export type TWatchModes = export type TWatchModes = 'test' | 'node' | 'service' | 'element' | 'website' | 'echo';
| 'test'
| 'node'
| 'service'
| 'element'
| 'website'
| 'echo';

View File

@ -31,7 +31,7 @@ export class TsWatch {
filePathToWatch: paths.cwd, filePathToWatch: paths.cwd,
commandToExecute: 'npm run test2', commandToExecute: 'npm run test2',
timeout: null, timeout: null,
}) }),
); );
break; break;
case 'node': case 'node':
@ -40,7 +40,7 @@ export class TsWatch {
filePathToWatch: paths.cwd, filePathToWatch: paths.cwd,
commandToExecute: 'npm run test', commandToExecute: 'npm run test',
timeout: null, timeout: null,
}) }),
); );
break; break;
case 'element': case 'element':
@ -51,7 +51,7 @@ export class TsWatch {
// lets create a standard server // lets create a standard server
logger.log( logger.log(
'info', 'info',
'bundling TypeScript files to "dist_watch" Note: This is for development only!' 'bundling TypeScript files to "dist_watch" Note: This is for development only!',
); );
this.typedserver = new plugins.typedserver.TypedServer({ this.typedserver = new plugins.typedserver.TypedServer({
cors: true, cors: true,
@ -75,13 +75,13 @@ export class TsWatch {
await bundleAndReloadElement(); await bundleAndReloadElement();
}, },
timeout: null, timeout: null,
}) }),
); );
// lets get the other ts folders // lets get the other ts folders
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd); let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
tsfolders = tsfolders.filter( tsfolders = tsfolders.filter(
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web' (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web',
); );
const smartshellInstance = new plugins.smartshell.Smartshell({ const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash', executor: 'bash',
@ -97,7 +97,7 @@ export class TsWatch {
await bundleAndReloadElement(); await bundleAndReloadElement();
}, },
timeout: null, timeout: null,
}) }),
); );
} }
@ -113,7 +113,7 @@ export class TsWatch {
await bundleAndReloadElement(); await bundleAndReloadElement();
}, },
timeout: null, timeout: null,
}) }),
); );
})(); })();
break; break;
@ -127,7 +127,7 @@ export class TsWatch {
}; };
let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd); let tsfolders = await plugins.smartfile.fs.listFolders(paths.cwd);
tsfolders = tsfolders.filter( tsfolders = tsfolders.filter(
(itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web' (itemArg) => itemArg.startsWith('ts') && itemArg !== 'ts_web',
); );
for (const tsfolder of tsfolders) { for (const tsfolder of tsfolders) {
this.watcherMap.add( this.watcherMap.add(
@ -138,7 +138,7 @@ export class TsWatch {
await bundleAndReloadWebsite(); await bundleAndReloadWebsite();
}, },
timeout: null, timeout: null,
}) }),
); );
} }
this.watcherMap.add( this.watcherMap.add(
@ -148,7 +148,7 @@ export class TsWatch {
await bundleAndReloadWebsite(); await bundleAndReloadWebsite();
}, },
timeout: null, timeout: null,
}) }),
); );
this.watcherMap.add( this.watcherMap.add(
new Watcher({ new Watcher({
@ -162,7 +162,17 @@ export class TsWatch {
await bundleAndReloadWebsite(); await bundleAndReloadWebsite();
}, },
timeout: null, timeout: null,
}) }),
);
this.watcherMap.add(
new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, './assets/'),
functionToCall: async () => {
await assetsHandler.processAssets();
await bundleAndReloadWebsite();
},
timeout: null,
}),
); );
})(); })();
break; break;
@ -172,7 +182,7 @@ export class TsWatch {
filePathToWatch: plugins.path.join(paths.cwd, './ts/'), filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
commandToExecute: 'npm run startTs', commandToExecute: 'npm run startTs',
timeout: null, timeout: null,
}) }),
); );
break; break;
case 'echo': case 'echo':

View File

@ -56,7 +56,7 @@ export class Watcher {
logger.log('ok', `executing ${this.options.commandToExecute} for the first time`); logger.log('ok', `executing ${this.options.commandToExecute} for the first time`);
} }
this.currentExecution = await this.smartshellInstance.execStreaming( this.currentExecution = await this.smartshellInstance.execStreaming(
this.options.commandToExecute this.options.commandToExecute,
); );
} else { } else {
console.log('no executionCommand set'); console.log('no executionCommand set');
@ -64,7 +64,7 @@ export class Watcher {
if (this.options.functionToCall) { if (this.options.functionToCall) {
this.options.functionToCall(); this.options.functionToCall();
} else { } else {
console.log('no functionToCall set.') console.log('no functionToCall set.');
} }
} }

View File

@ -7,9 +7,9 @@ import { TsWatch } from './tswatch.classes.tswatch.js';
const tswatchCli = new plugins.smartcli.Smartcli(); const tswatchCli = new plugins.smartcli.Smartcli();
// standard behaviour will assume gitzone setup // standard behaviour will assume gitzone setup
tswatchCli.standardCommand().subscribe((argvArg => { tswatchCli.standardCommand().subscribe((argvArg) => {
tswatchCli.triggerCommand('npm', {}); tswatchCli.triggerCommand('npm', {});
})) });
tswatchCli.addCommand('element').subscribe(async (argvArg) => { tswatchCli.addCommand('element').subscribe(async (argvArg) => {
logger.log('info', `running watch task for a gitzone element project`); logger.log('info', `running watch task for a gitzone element project`);

View File

@ -4,16 +4,12 @@ export { path };
// @gitzone scope // @gitzone scope
import * as tsbundle from '@git.zone/tsbundle'; import * as tsbundle from '@git.zone/tsbundle';
export { export { tsbundle };
tsbundle
}
// @apiglobal scope // @apiglobal scope
import * as typedserver from '@api.global/typedserver'; import * as typedserver from '@api.global/typedserver';
export { export { typedserver };
typedserver,
}
// @pushrocks scope // @pushrocks scope
import * as lik from '@push.rocks/lik'; import * as lik from '@push.rocks/lik';

View File

@ -6,9 +6,11 @@
"module": "NodeNext", "module": "NodeNext",
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
"baseUrl": ".",
"paths": {}
}, },
"exclude": [ "exclude": [
"dist_*/**/*.d.ts" "dist_*/**/*.d.ts"
] ]
} }