Skip to content

Commit

Permalink
GitHub Actions Setup (#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Dirk Peter <[email protected]>
  • Loading branch information
dirk-peter-c8y and Dirk Peter authored May 27, 2024
1 parent 85af55e commit cd271b3
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Create artifact (zip) on tag
run-name: ${{ github.actor }} set a tag

on:
push:
tags:
- '*'
# - 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: 'npm'
- run: npm ci

- run: echo "PACKAGE_JSON=$(jq -c . < package.json)" >> $GITHUB_ENV

# - run: npm lint
- run: npm test
- run: npm run build

- run: echo "ARCHIVE_NAME=${{ fromJson(env.PACKAGE_JSON).name }}_${{ fromJson(env.PACKAGE_JSON).version }}.zip" >> $GITHUB_ENV

- name: Zip Build
run: |
cd ./dist/apps/${{ fromJson(env.PACKAGE_JSON).name }}
zip -r ../../${{ env.ARCHIVE_NAME }} ./
# - name: Archive production artifacts
# uses: actions/upload-artifact@v4
# with:
# name: tag_archive
# path: dist/${{ env.ARCHIVE_NAME }}
# retention-days: 1

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: dist/${{ env.ARCHIVE_NAME }}
asset_name: ${{ env.ARCHIVE_NAME }}
asset_content_type: application/zip
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build & Test
run-name: ${{ github.actor }} is testing the implementation

on:
pull_request:
branches: ['main']

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x, 18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci

- run: npm run build
- run: npm test
# - run: npm lint
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

---

[![Node.js CI](https://github.com/SoftwareAG/cumulocity-reminder-plugin/actions/workflows/test.yml/badge.svg)](https://github.com/SoftwareAG/cumulocity-reminder-plugin/actions/workflows/test.yml)

_TBD_

---
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
module.exports = {
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.js'],
transformIgnorePatterns: ['/!node_modules\\/lodash-es/']
transformIgnorePatterns: ['/!node_modules\\/lodash-es/'],
collectCoverageFrom: ['./plugin/**']
};
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"build": "c8ycli build",
"postbuild": "cd ./dist/apps/${npm_package_name} && zip -r ../../${npm_package_name}_${npm_package_version}.zip ./",
"deploy": "c8ycli deploy",
"test": "jest --passWithNoTests",
"test:clear": "jest --clearCache",
"test:watch": "jest --watch",
"test:coverage": "npm test -- --coverage",
"locale-extract": "c8ycli locale-extract",
"postinstall": "ngcc"
},
Expand Down

0 comments on commit cd271b3

Please sign in to comment.