Skip to content

(Fix): Fix setting vars to false and add testing framework #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Pull Request
run-name: Pull Request for ${{ github.ref_name }} by ${{ github.actor }}

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

permissions: read-all

on:
pull_request: {}

jobs:
trunk_code_quality_runner:
name: Trunk Code Quality runner [linux]
runs-on: ubuntu-latest
permissions:
checks: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Install pnpm
uses: trunk-io/trunk-action/install@v1
with:
tools: pnpm

- name: Install dependencies
run: pnpm install

- name: Trunk Check
uses: trunk-io/trunk-action@v1

test_and_upload:
name: Test and Upload
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Install pnpm
uses: trunk-io/trunk-action/install@v1
with:
tools: pnpm

- name: Run tests
shell: bash
run: |
pnpm install
pnpm test

# Do NOT continue-on-error for these uploads
- name: Trunk Analytics Uploader (Prod)
uses: ./
with:
junit-paths: junit.xml
org-slug: trunk
token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
allow-missing-junit-files: "false"
# Forces the uploader to not continue-on-error and use the CLI exit code
quarantine: "true"

- name: Trunk Analytics Uploader (Staging)
uses: ./
with:
junit-paths: junit.xml
org-slug: trunk-staging-org
token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
allow-missing-junit-files: "false"
# Forces the uploader to not continue-on-error and use the CLI exit code
quarantine: "true"
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk-staging.io
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
junit.xml
1 change: 1 addition & 0 deletions .trunk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
plugins
user_trunk.yaml
user.yaml
tmp
40 changes: 28 additions & 12 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,51 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.18.1
version: 1.22.8
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.4.1
ref: v1.6.6
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.21.0
- node@18.12.1
- node@18.20.5
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- checkov@3.1.50
- actionlint@1.7.4
- checkov@3.2.334
- eslint@9.16.0
- git-diff-check
- markdownlint@0.38.0
- prettier@3.1.1
- shellcheck@0.9.0
- markdownlint@0.43.0
- osv-scanner@1.9.1
- prettier@3.4.2
- shellcheck@0.10.0
- shfmt@3.6.0
- trivy@0.48.1
- trufflehog@3.63.7
- yamllint@1.33.0
- sort-package-json@2.12.0
- trivy@0.58.0
- trufflehog@3.86.0
- trunk-toolbox@0.5.4
- yamllint@1.35.1
actions:
disabled:
- trunk-announce
definitions:
- id: test-pre-push
display_name: Arg Tests
runtime: node
packages_file: package.json
run: npm test
triggers:
- git_hooks: [pre-push]
enabled:
- test-pre-push
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
tools:
enabled:
- pnpm@9.15.0
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ runs:
- name: Upload test results
run: ${GITHUB_ACTION_PATH}/script.sh ${{ inputs.run }}
shell: bash
continue-on-error: ${{ inputs.run == '' && inputs.quarantine == '' }}
continue-on-error: ${{ inputs.run == '' && (inputs.quarantine == '' || inputs.quarantine == 'false') }}
env:
JUNIT_PATHS: ${{ inputs.junit-paths }}
ORG_URL_SLUG: ${{ inputs.org-slug }}
Expand Down
40 changes: 40 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import path from "node:path";
import url from "node:url";

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import pluginJest from "eslint-plugin-jest";

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
{
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: path.dirname(url.fileURLToPath(import.meta.url)),
},
},
},
{
rules: {
"no-console": "error",
},
},
{
// update this to match your test files
files: ["**/*.test.ts"],
plugins: { jest: pluginJest },
languageOptions: {
globals: pluginJest.environments.globals.globals,
},
rules: {
"jest/no-disabled-tests": "warn",
"jest/no-focused-tests": "error",
"jest/no-identical-title": "error",
"jest/prefer-to-have-length": "warn",
"jest/valid-expect": "error",
},
},
);
22 changes: 22 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// eslint-disable-next-line no-undef
process.env.JEST_JUNIT_ADD_FILE_ATTRIBUTE = "true";

const config = {
preset: "ts-jest",
testEnvironment: "node",
extensionsToTreatAsEsm: [".ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
reporters: ["default", "jest-junit"],
transform: {
"^.+\\.ts?$": [
"ts-jest",
{
useESM: true,
},
],
},
};

export default config;
23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "trunk-analytics-uploader",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@types/eslint__js": "^8.42.3",
"@types/jest": "^29.5.14",
"@types/node": "^22.7.9",
"eslint": "^9.16.0",
"eslint-plugin-jest": "^28.9.0",
"jest": "^29.7.0",
"jest-junit": "^16.0.0",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.0"
}
}
Loading
Loading