Skip to content

Commit

Permalink
Updated workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
patricia-martinez-imatia committed Oct 11, 2023
1 parent f5f1075 commit 732adf4
Show file tree
Hide file tree
Showing 7 changed files with 1,718 additions and 5,784 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,33 @@ name: Build CI
on:
pull_request:
types: [closed]
branches: [8.x.x, hotfix/8.*]
branches: [15.x.x, hotfix/15.*]
paths: ['src/**']

jobs:
build:
if: github.event_name == 'pull_request' && github.event.pull_request.merged == true
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- name: 'Checkout code'
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: 'Cache node modules'
uses: actions/cache@v1
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node 12.x
uses: actions/setup-node@v1
- name: Node 18.x
uses: actions/setup-node@v3
with:
node-version: 12.13.0
node-version: 18.10.0

- name: npm install and npm run build
run: |
npm i
npm run build
45 changes: 34 additions & 11 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ name: Build Release
on:
pull_request:
types: [closed]
branches: [master]
branches: [main.15.x]
workflow_dispatch:
inputs:
BASELINE:
description: 'Release branch'
required: true
default: 'master'
default: 'main.15.x'

env:
NPM_REGISTRY: https://registry.npmjs.org/
CI_EMAIL: ontimize-web@imatia.com
CI_USERNAME: ontimize-web
DEVELOP_BRANCH: 8.x.x
DEVELOP_BRANCH: 15.x.x

jobs:
build:
Expand All @@ -34,26 +34,35 @@ jobs:
ref: ${{ env.BASELINE_BRANCH }}
fetch-depth: 0

- name: Node 12.x
- name: 'Cache node modules'
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Node 18.x
uses: actions/setup-node@v3
with:
node-version: 12.13.0
node-version: 18.10.0
registry-url: ${{ env.NPM_REGISTRY }}

- name: obtain package.json version
id: project
run: |
echo ::set-output name=version::$(node -pe "require('./package.json')['version']")
echo "version=$(node -pe "require('./package.json')['version']")" >> $GITHUB_OUTPUT
- name: abort if SNAPSHOT
if: "contains(steps.project.outputs.version, 'SNAPSHOT')"
run: |
echo "Version ${{ steps.project.outputs.version }} is not a properly named for RELEASE"
exit 1
- name: GitHub Release / Create release
uses: ncipollo/release-action@2792aea87063cfd0d27953ac38e3ab45afacc154
- name: GitHub Release / Create release
uses: ncipollo/release-action@2792aea87063cfd0d27953ac38e3ab45afacc154
with:
commit: ${{ env.BASELINE_BRANCH }}
tag: ${{ steps.project.outputs.version }}
name: ${{ steps.project.outputs.version }}
token: ${{ secrets.OWEB_GH_TOKEN_PUSH }}
Expand All @@ -65,18 +74,32 @@ jobs:
git config user.name "$CI_USERNAME"
git config user.email "$CI_EMAIL"
- name: bumping version in package.json
run: |
npm version $(npm version minor --no-git-tag-version)-SNAPSHOT-0 --no-git-tag-version
- name: bumping version in internal package.json
working-directory: .
run: |
npm version $(npm version minor --no-git-tag-version)-SNAPSHOT-0 --no-git-tag-version
- name: Create sync branch
run: |
version=${{ steps.project.outputs.version }}
git checkout -b sync/release-$version-to-develop
npm version $(npm version minor --no-git-tag-version)-SNAPSHOT-0 --no-git-tag-version
git add .
git commit --allow-empty -m "Prepare next development iteration"
git commit -m "Prepare next development iteration"
git push origin sync/release-$version-to-develop
- name: Create pull request
env:
GITHUB_TOKEN: ${{ secrets.OWEB_GH_TOKEN_PUSH }}
run: |
version=${{ steps.project.outputs.version }}
gh pr create -B ${{ env.DEVELOP_BRANCH }} -H sync/release-$version-to-develop --title "Sync release $version to develop" --body "Automated pull request for synchronizing released version into develop branch"
MESSAGE="
Automated pull request for synchronizing released version ($version) into develop branch
### 💡 Merge Strategy: Create a merge commit
"
gh pr create -B ${{ env.DEVELOP_BRANCH }} -H sync/release-$version-to-develop --title "Sync release $version to develop" --body "$(echo -e "$MESSAGE")"
113 changes: 104 additions & 9 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ on:
default: 'minor'
type: choice
options:
- 'minor'
- 'hotfix'
- "minor"
- "hotfix"
- "rc"
- "beta"
RELEASE_CANDIDATE_VERSION:
description: "Release candidate version (e.g. 15.0.0-rc.0)"
BETA_VERSION:
description: "Beta version (e.g. 15.0.0-beta.0)"

env:
NPM_REGISTRY: https://registry.npmjs.org/
CI_EMAIL: ontimize-web@imatia.com
CI_USERNAME: ontimize-web
MAIN_BRANCH: master
DEVELOP_BRANCH: 8.x.x
MAIN_BRANCH: main.15.x
DEVELOP_BRANCH: 15.x.x

jobs:
build:
runs-on: ubuntu-20.04
Expand All @@ -31,23 +37,68 @@ jobs:
if [ "${{ github.event.inputs.RELEASE_TYPE }}" = "hotfix" ]; then
BASELINE_BRANCH=${{ env.MAIN_BRANCH }}
isHotfix=1
isMinor=0
isRC=0
isBeta=0
elif [ "${{ github.event.inputs.RELEASE_TYPE }}" = "rc" ]; then
BASELINE_BRANCH=${{ env.DEVELOP_BRANCH }}
isHotfix=0
isMinor=0
isRC=1
isBeta=0
elif [ "${{ github.event.inputs.RELEASE_TYPE }}" = "beta" ]; then
BASELINE_BRANCH=${{ env.DEVELOP_BRANCH }}
isHotfix=0
isMinor=0
isRC=0
isBeta=1
else
BASELINE_BRANCH=${{ env.DEVELOP_BRANCH }}
isHotfix=0
isMinor=1
isRC=0
isBeta=0
fi
echo "BASELINE_BRANCH=$BASELINE_BRANCH" >> $GITHUB_ENV
echo "isHotfix=$isHotfix" >> $GITHUB_OUTPUT
echo "isMinor=$isMinor" >> $GITHUB_OUTPUT
echo "isRC=$isRC" >> $GITHUB_OUTPUT
echo "isBeta=$isBeta" >> $GITHUB_OUTPUT
- name: Setup release candidate version
if: ${{ steps.parameters.outputs.isRC == true }}
id: release-candidate
run: |
versionNumber=${{ github.event.inputs.RELEASE_CANDIDATE_VERSION}}
if [[ $versionNumber =~ ^[0-9]+\.[0-9]+\.[0-9]+\-rc\.[0-9]+ ]]; then
echo "version=${BASH_REMATCH[0]}" >> $GITHUB_OUTPUT
else
echo "Invalid Release Candidate version"
exit 1
fi
- name: Setup Beta version
if: ${{ steps.parameters.outputs.isBeta == true }}
id: beta
run: |
versionNumber=${{ github.event.inputs.BETA_VERSION}}
if [[ $versionNumber =~ ^[0-9]+\.[0-9]+\.[0-9]+\-beta\.[0-9]+ ]]; then
echo "version=${BASH_REMATCH[0]}" >> $GITHUB_OUTPUT
else
echo "Invalid Beta version"
exit 1
fi
- name: Checkout merge commit
uses: actions/checkout@v3
with:
ref: ${{ env.BASELINE_BRANCH }}
fetch-depth: 0

- name: Node 12.x
- name: Node 18.x
uses: actions/setup-node@v3
with:
node-version: 12.13.0
node-version: 18.10.0
registry-url: ${{ env.NPM_REGISTRY }}

- name: obtain package.json version
Expand All @@ -62,21 +113,64 @@ jobs:
## MINOR
- name: bumping minor version in package.json
if: ${{ steps.parameters.outputs.isHotfix == false }}
if: ${{ steps.parameters.outputs.isMinor == true }}
run: |
version=$(echo "${{ steps.project.outputs.version }}" | sed 's/-SNAPSHOT-[0-9]//')
npm version $version --no-git-tag-version
echo "RELEASE_VERSION=$(node -pe "require('./package.json')['version']")" >> $GITHUB_ENV
- name: bumping minor version in internal package.json
if: ${{ steps.parameters.outputs.isMinor == true }}
working-directory: .
run: |
version=$(echo "${{ steps.project.outputs.version }}" | sed 's/-SNAPSHOT-[0-9]//')
npm version $version --no-git-tag-version
## RELEASE CANDIDATE
- name: bumping minor version in package.json
if: ${{ steps.parameters.outputs.isRC == true }}
run: |
version=$(echo "${{ steps.release-candidate.outputs.version }}")
npm version $version --no-git-tag-version
echo "RELEASE_VERSION=$(node -pe "require('./package.json')['version']")" >> $GITHUB_ENV
- name: bumping minor version in internal package.json
if: ${{ steps.parameters.outputs.isRC == true }}
working-directory: .
run: |
version=$(echo "${{ steps.release-candidate.outputs.version }}")
npm version $version --no-git-tag-version
## Beta
- name: bumping minor version in package.json
if: ${{ steps.parameters.outputs.isBeta == true }}
run: |
version=$(echo "${{ steps.beta.outputs.version }}")
npm version $version --no-git-tag-version
echo "RELEASE_VERSION=$(node -pe "require('./package.json')['version']")" >> $GITHUB_ENV
- name: bumping minor version in internal package.json
if: ${{ steps.parameters.outputs.isBeta == true }}
working-directory: .
run: |
version=$(echo "${{ steps.beta.outputs.version }}")
npm version $version --no-git-tag-version
## HOTFIX
- name: bumping hotfix version in package.json
if: ${{ steps.parameters.outputs.isHotfix == true }}
run: |
npm version patch --no-git-tag-version
echo "RELEASE_VERSION=$(node -pe "require('./package.json')['version']")" >> $GITHUB_ENV
- name: bumping hotfix version in internal package.json
if: ${{ steps.parameters.outputs.isHotfix == true }}
working-directory: .
run: |
npm version patch --no-git-tag-version
- name: Create release branch
if: ${{ steps.parameters.outputs.isHotfix == false }}
if: ${{ steps.parameters.outputs.isMinor == true }} || ${{ steps.parameters.outputs.isRC == true }} || ${{ steps.parameters.outputs.isBeta == true }}
run: |
version=${{ env.RELEASE_VERSION }}
git checkout -b release/$version
Expand Down Expand Up @@ -110,3 +204,4 @@ jobs:
run: |
version=${{ env.RELEASE_VERSION }}
gh pr create -B ${{ env.MAIN_BRANCH }} -H hotfix/$version --title "Hotfix $version" --body "" --draft --label "release"
7 changes: 6 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,12 @@
"src/assets/css/app.scss",
"src/styles.scss"
],
"scripts": []
"scripts": [],
"stylePreprocessorOptions": {
"includePaths": [
"./node_modules"
]
}
}
},
"e2e": {
Expand Down
15 changes: 9 additions & 6 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,30 @@ module.exports = function (config) {
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-sonarqube-unit-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, './coverage/ontimize-web-ngx-playground'),
reports: ['html', 'lcovonly', 'text-summary'],
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/ontimize-web-ngx-playground'),
subdir: '.',
reporters: [
{ type: 'lcovonly' }
],
fixWebpackSourcePaths: true
},
sonarQubeUnitReporter: {
sonarQubeUnitReporter: {
sonarQubeVersion: 'LATEST',
outputFile: './reports/ut_report.xml',
overrideTestDescription: true,
testPaths: ['./src'],
testFilePattern: '.spec.ts',
useBrowserName: false
},
reporters: ['progress', 'kjhtml', 'sonarqubeUnit'],
reporters: ['progress', 'kjhtml', 'sonarqubeUnit', 'coverage'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
Expand Down
Loading

0 comments on commit 732adf4

Please sign in to comment.