Skip to content

Commit

Permalink
fix(cd): it should behave correctly (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thenkei authored Sep 17, 2024
1 parent 117ed15 commit 02d7d2f
Show file tree
Hide file tree
Showing 6 changed files with 946 additions and 1,094 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,43 @@ jobs:
build:
name: Installing & Building
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
persist-credentials: false # GITHUB_TOKEN must not be set for the semantic release
# https://github.com/semantic-release/semantic-release/blob/master/docs/recipes/ci-configurations/github-actions.md#pushing-packagejson-changes-to-your-repository
- uses: actions/setup-node@v3
with:
node-version: 18.20.1

- name: Install
run: yarn

- name: Lint, Test & Build on branch
if: github.ref != 'refs/heads/main'
run: npx nx affected --base=origin/main -t lint test build

- name: Lint, Test & Build on main
if: |
github.event_name == 'push'
&& (
github.ref == 'refs/heads/main'
)
run: npx nx affected --base=HEAD~1 -t lint test build
run: npx nx affected --base=origin/main~1 --head=origin/main -t lint test build

- name: Publish from main
if: |
github.event_name == 'push'
&& (
github.ref == 'refs/heads/main'
)
run: npx nx affected --base=HEAD~1 -t publish:package
run: npx nx affected --base=origin/main~1 --head=origin/main -t publish:package
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
Expand Down
12 changes: 10 additions & 2 deletions .releaserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ module.exports = {
],
plugins: [
[
'@semantic-release/exec',
'@semantic-release/commit-analyzer',
{
analyzeCommitsCmd: "../../commit-analyser.sh"
preset: 'angular',
releaseRules: [
// Example: `type(scope): subject [force release]`
{ subject: '*\\[force release\\]*', release: 'patch' },
// Example: `type(scope): subject [force-release]`
{ subject: '*\\[force-release\\]*', release: 'patch' },
],
},
],
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
'@semantic-release/npm',
[
'@semantic-release/git',
Expand Down
9 changes: 0 additions & 9 deletions commit-analyser.sh

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {},
"private": true,
"devDependencies": {
"@semantic-release/changelog": "6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/jest": "^29.5.9",
Expand All @@ -22,7 +23,7 @@
"nx": "15.9.2",
"prettier": "^2.8.2",
"prettier-eslint": "^15.0.1",
"semantic-release": "21.1.2",
"semantic-release": "22.0.12",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
Expand Down
12 changes: 12 additions & 0 deletions packages/agent-nodejs-testing/src/units/add-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ export function getFormFieldValueAction<ReturnType>(
action: TestableAction,
label: string,
): (actionContext: ActionContext) => Promise<ReturnType> {
if (!action.definition.form) return null;

if (action.definition.form instanceof Function) {
throw new Error('Use getDynamicFormFieldValueAction function helper');
}

return (
getFormFieldAction(action, label) as {
value: (actionContext: ActionContext) => Promise<ReturnType>;
Expand All @@ -71,6 +77,12 @@ export async function getDynamicFormFieldValueAction<ReturnType>(
label: string,
actionContext: ActionContext,
): Promise<(actionContext: ActionContext) => Promise<ReturnType>> {
if (!action.definition.form) return null;

if (!(action.definition.form instanceof Function)) {
throw new Error('Use getFormFieldValueAction function helper');
}

return (
(await getDynamicFormFieldAction(action, label, actionContext)) as {
value: (actionContext: ActionContext) => Promise<ReturnType>;
Expand Down
Loading

0 comments on commit 02d7d2f

Please sign in to comment.