Skip to content

Commit

Permalink
initial commit (#1)
Browse files Browse the repository at this point in the history
* initial commit

* addressing the issues with the linter

* fixing the transpiller issue

* fixing the filename

* now using the right case on the test filename

* fixed the errors with the tests

* fzxing the action test

* fixing the linting process

* fixing the issues with the package-lock.json

* further fixes to the action pipeline

* finxing the linter
  • Loading branch information
cjlapao authored Mar 26, 2024
1 parent a0c0c58 commit 7be7f3a
Show file tree
Hide file tree
Showing 61 changed files with 13,178 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
lib/
dist/
node_modules/
coverage/
12 changes: 12 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
}
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto eol=lf

dist/** -diff linguist-generated=true
2 changes: 2 additions & 0 deletions .github/linters/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ignorePatterns:
- "**/coverage/.*"
- "**/__tests__/.*"
- "*.json"
- /src/index.ts

parser: "@typescript-eslint/parser"

Expand Down Expand Up @@ -52,4 +53,5 @@ rules:
"prettier/prettier": "error",
"semi": "off",
"space-before-function-paren": 0,
"no-shadow": "off",
}
54 changes: 0 additions & 54 deletions .github/workflow_scripts/generate-blog-records.sh

This file was deleted.

6 changes: 0 additions & 6 deletions .github/workflow_scripts/get-latest-changlog-version.sh

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ jobs:
id: test-action
uses: ./
with:
badge-path: ./test-badge.svg
title: stable
host_url: localhost
operation: 'test'

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.badge-path }}"
run: echo "${{ steps.test-action.outputs.vm_id }}"
5 changes: 4 additions & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ jobs:
NEW_VERSION=$(./.github/workflow_scripts/increment-version.sh -t ${{ inputs.version }} -f VERSION)
echo "$NEW_VERSION" > ./VERSION
npm run test
npm run bundle
sed -i "s/\"version\": \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\": \"$NEW_VERSION\"/g" package.json
git checkout -b release/"$NEW_VERSION"
git add VERSION ./dist/*
git add package.json VERSION ./dist/* ./badges/*
git commit -m "Release action version $NEW_VERSION"
git push --set-upstream origin release/$NEW_VERSION
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ jobs:
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_ALL_CODEBASE: true
VALIDATE_JSCPD: false
VALIDATE_CHECKOV: false
VALIDATE_GITHUB_ACTIONS: false
104 changes: 104 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-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
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

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

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*

# IDE files
.idea
.vscode
*.code-workspace
.local
9 changes: 9 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{

Check warning on line 1 in .markdownlint.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"no-duplicate-heading": {
"siblings_only": true
},
"line-length": {
"line_length": 80,
"tables": false
}
}
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.6.0
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
node_modules/
coverage/
16 changes: 16 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{

Check warning on line 1 in .prettierrc.json

View workflow job for this annotation

GitHub Actions / Lint Codebase

File ignored by default.
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"quoteProps": "as-needed",
"jsxSingleQuote": false,
"trailingComma": "none",
"bracketSpacing": true,
"bracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "always",
"htmlWhitespaceSensitivity": "css",
"endOfLine": "lf"
}
3 changes: 3 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Repository CODEOWNERS

* @cjlapao
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright GitHub

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Parallels Desktop DevOps Github Action
# Parallels Desktop DevOps GitHub Action

![coverage](https://raw.githubusercontent.com/Parallels/parallels-desktop-github-action/main/badges/coverage.svg)
[![Lint Codebase](https://github.com/Parallels/parallels-desktop-github-action/actions/workflows/linter.yml/badge.svg)](https://github.com/Parallels/parallels-desktop-github-action/actions/workflows/linter.yml)
[![CI](https://github.com/Parallels/parallels-desktop-github-action/actions/workflows/ci.yml/badge.svg)](https://github.com/Parallels/parallels-desktop-github-action/actions/workflows/ci.yml)

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
81 changes: 81 additions & 0 deletions __tests__/amplitude.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Telemetry } from '../src/telemetry/telemetry'
import * as amplitude from '@amplitude/analytics-node' // Import the 'amplitude' module

describe('Telemetry', () => {
let telemetry: Telemetry

beforeEach(() => {
telemetry = new Telemetry()
})

it('should set the user ID correctly', () => {
const userId = 'test-user'
telemetry.setUserId(userId)

expect(telemetry['userId']).toBe(userId)
})

it('should set the license correctly', () => {
const license = 'test-license'
telemetry.setLicense(license)

expect(telemetry['license']).toBe(license)
})

it('should track an event without license', () => {
const event = {
event: 'test-event',
properties: [
{ name: 'property1', value: 'value1' },
{ name: 'property2', value: 'value2' }
]
}
const trackSpy = jest.spyOn(amplitude, 'track')

telemetry.track(event)

expect(trackSpy).toHaveBeenCalledWith(
event.event,
{
property1: 'value1',
property2: 'value2'
},
{ user_id: 'github-action' }
)
})

it('should track an event with license', () => {
const event = {
event: 'test-event',
properties: [
{ name: 'property1', value: 'value1' },
{ name: 'property2', value: 'value2' }
]
}
const license = 'test-license'
telemetry.setLicense(license)
const trackSpy = jest.spyOn(amplitude, 'track')

telemetry.track(event)

expect(trackSpy).toHaveBeenCalledWith(
event.event,
{
property1: 'value1',
property2: 'value2',
license
},
{ user_id: 'github-action' }
)
})

it('should flush the telemetry', () => {
const flushSpy = jest.spyOn(amplitude, 'flush')

telemetry.flush()

expect(flushSpy).toHaveBeenCalled()
})

// Add more test cases to cover different scenarios
})
Loading

0 comments on commit 7be7f3a

Please sign in to comment.