Skip to content

Commit

Permalink
feat(infra): modernize infra
Browse files Browse the repository at this point in the history
  • Loading branch information
djMax committed Nov 9, 2023
1 parent cda2518 commit cf8ab36
Show file tree
Hide file tree
Showing 11 changed files with 3,067 additions and 300 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Node CI

on:
pull_request:
types: [assigned, opened, synchronize, reopened]
push:
branches:
- main

permissions:
contents: read

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Cleanup stale actions
uses: styfle/cancel-workflow-action@0.11.0
with:
access_token: ${{ github.token }}

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version: 20
- name: npm install, lint, build, and test
run: |
yarn install --immutable
yarn lint
yarn build
yarn test
env:
CI: true

publish-npm:
needs: build
permissions:
contents: write
issues: write
id-token: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- run: yarn install --immutable
- run: yarn build

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
run: |
yarn dlx semantic-release
39 changes: 0 additions & 39 deletions .github/workflows/npm_publish.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/pull_requests.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
10 changes: 10 additions & 0 deletions .trunk/configs/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Autoformatter friendly markdownlint config (all formatting rules disabled)
default: true
blank_lines: false
bullet: false
html: false
indentation: false
line_length: false
spaces: false
url: false
whitespace: false
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
10 changes: 10 additions & 0 deletions .trunk/configs/.yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ['{|}']
empty-values:
forbid-in-block-mappings: true
forbid-in-flow-mappings: true
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
41 changes: 41 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.17.2
plugins:
sources:
- id: trunk
ref: v1.2.6
uri: https://github.com/trunk-io/plugins
runtimes:
enabled:
- go@1.21.0
- node@18.12.1
- python@3.10.8
lint:
enabled:
- actionlint@1.6.26
- checkov@3.0.29
- eslint@8.53.0
- git-diff-check
- markdownlint@0.37.0
- osv-scanner@1.4.3
- prettier@3.0.3
- shellcheck@0.9.0
- shfmt@3.6.0
- trivy@0.47.0
- trufflehog@3.62.1
- yamllint@1.32.0
ignore:
- linters: [ALL]
paths:
- .yarn/**
- yarn.lock
actions:
enabled:
- commitlint
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
4 changes: 3 additions & 1 deletion __tests__/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import http from 'http';

import { expect, test, vi } from 'vitest';
import { ReadableSpan, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base';
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { FetchInstrumentation } from '../src';
import { SpanStatusCode } from '@opentelemetry/api';

import { FetchInstrumentation } from '../src';

test('Basic function', async () => {
const provider = new NodeTracerProvider({});
const exportedSpans: ReadableSpan[] = [];
Expand Down
31 changes: 24 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "opentelemetry-instrumentation-fetch-node",
"version": "1.1.0",
"version": "0.0.0",
"description": "OpenTelemetry Node 18+ native fetch automatic instrumentation package",
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"test": "vitest",
"build": "tsc -p tsconfig.build.json",
"clean": "yarn dlx rimraf ./build",
"prepare": "husky install",
"lint": "eslint src"
},
"engines": {
Expand All @@ -27,24 +26,42 @@
"fetch",
"undici"
],
"lint-staged": {
"*.{js,jsx,ts,tsx}": "yarn eslint --cache --fix"
},
"config": {
"coconfig": "@openapi-typescript-infra/coconfig"
},
"release": {
"branches": [
"main"
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
"publishCmd": "yarn dlx pinst --disable"
}
],
"@semantic-release/npm",
"@semantic-release/github"
]
},
"devDependencies": {
"@commitlint/config-conventional": "^18.1.0",
"@openapi-typescript-infra/coconfig": "^4.2.2",
"@opentelemetry/sdk-trace-base": "^1.17.0",
"@opentelemetry/sdk-trace-node": "^1.17.0",
"@semantic-release/commit-analyzer": "^11.1.0",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/github": "^9.2.2",
"@semantic-release/release-notes-generator": "^12.1.0",
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"coconfig": "^1.0.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.29.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"semantic-release": "^22.0.7",
"typescript": "^5.2.2",
"vitest": "^0.34.6"
},
Expand Down
Loading

0 comments on commit cf8ab36

Please sign in to comment.