Skip to content

Commit

Permalink
feat: restructure project (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
reey authored May 1, 2024
1 parent e976293 commit ce91adc
Show file tree
Hide file tree
Showing 92 changed files with 10,602 additions and 38,533 deletions.
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Ignore everything
*

# Allow files and directories
!/backend
!/package.json
!/node-red-c8y-storage-plugin
!/node-red-contrib-c8y-client
!/yarn.lock
!/settings.js
!/index.js

# Ignore unnecessary files inside allowed directories
# This should go after the allowed directories
**/node_modules
**/*.zip
**/*.tar
**/.env
**/dist
**/lib
19 changes: 12 additions & 7 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,29 @@
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/frontend" # Location of package manifests
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
assignees:
- "reey"
allow:
- dependency-type: "direct"
dependency-name: "@c8y*"
labels:
- "npm"
- "yarn"
- "dependencies"
- "c8y"
reviewers:
- "reey"
groups:
web-sdk:
patterns:
- "@c8y/*"
update-types:
# - "minor"
- "minor"
- "patch"
angular:
patterns:
- "@angular/*"
- "@angular-devkit/*"
- "@schematics/angular"
update-types:
- "minor"
- "patch"

108 changes: 14 additions & 94 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
branches: [main]
pull_request:
branches: [main]

name: Main CI

env:
NODE_VERSION: '14'
NODE_VERSION: '18'

jobs:
build:
Expand All @@ -23,123 +21,45 @@ jobs:
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Check out Git repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Mark backend version as SNAPSHOT
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
run: |
cd backend
sed -i '/\"version\"/s/\"\,/\-SNAPSHOT\"\,/g' cumulocity.json
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Set C8Y_VERSION env variable
run: echo "C8Y_VERSION=$(node -p -e "require('./frontend/package.json').dependencies['@c8y/ngx-components']")" >> $GITHUB_ENV

- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
cache: 'yarn'

- name: Install Node.js dependencies
run: |
cd frontend
npm ci
- name: 🕵️‍♂️ Lint
run: |
cd frontend
npm run lint --if-present
- name: 🧪 Test
run: |
cd frontend
npm test --if-present
yarn install --frozen-lockfile --immutable --non-interactive --prefer-offline
- name: 🚧 Build Frontend
run: |
cd frontend
npm run build:ci
yarn build:ui
- name: Upload Frontend Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: node-red-ui-${{ env.C8Y_VERSION }}-${{ github.event.number }}-${{ github.run_id }}
name: node-red-ui-${{ github.event.number }}-${{ github.run_id }}
if-no-files-found: error
retention-days: 5
path: frontend/dist/apps/sag-ps-iot-pkg-node-red-ui/
path: cumulocity-node-red-ui/dist/cumulocity-node-red-ui/

- name: 🚧 Build Backend
run: |
cd backend
docker build -t node-red-ms .
docker save node-red-ms -o image.tar
- name: Upload Backend Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: node-red-${{ env.C8Y_VERSION }}-${{ github.event.number }}-${{ github.run_id }}
name: node-red-${{ github.event.number }}-${{ github.run_id }}
if-no-files-found: error
retention-days: 5
path: |
backend/cumulocity.json
backend/image.tar
- name: 🎁 Zip Frontend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cd frontend/dist/apps/sag-ps-iot-pkg-node-red-ui
zip -r -q ../../../node-red-ui.zip *
- name: 🎁 Zip Backend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
cd backend
zip --junk-paths node-red cumulocity.json image.tar
- name: Create Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ env.RELEASE_VERSION }} based on ${{ env.C8Y_VERSION }}
draft: false
prerelease: false

- name: Upload Release Asset Frontend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: upload-release-asset-frontend
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./frontend/node-red-ui.zip
asset_name: node-red-ui-${{ env.C8Y_VERSION }}-${{ env.RELEASE_VERSION }}.zip
asset_content_type: application/zip

- name: Upload Release Asset Backend
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
id: upload-release-asset-backend
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./backend/node-red.zip
asset_name: node-red.zip
asset_content_type: application/zip
cumulocity.json
image.tar
41 changes: 41 additions & 0 deletions .github/workflows/semantic-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Semantic-Release
on:
workflow_dispatch:

env:
NODE_VERSION: ${{ '18' }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
name: Set release tag
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
initial-version: ${{ steps.save-initial-version.outputs.version }}
version: ${{ steps.save-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}

- name: Install Dependencies
run: |
npm i -g @semantic-release/changelog@^6.0.3 @semantic-release/exec@^6.0.3 @semantic-release/git@^10.0.1 semantic-release@^20.1.0
- name: Release
env:
GITHUB_TOKEN: ${{ github.token }}
GH_TOKEN: ${{ github.token }}
GITHUB_URL: ${{ github.server_url }}
HUSKY: 0
run: semantic-release
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

*.zip
*.tar
Loading

0 comments on commit ce91adc

Please sign in to comment.