Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b3f8c43
Update ci.yml
nofarb Jun 12, 2025
0537289
Update package.json
nofarb Jun 12, 2025
515a571
Update vite.config.js
nofarb Jun 12, 2025
cd164d3
Update enforce-license-compliance.yml
nofarb Jun 12, 2025
094a266
Update vite.config.js
nofarb Jun 12, 2025
3d6580b
Update package.json
nofarb Jun 12, 2025
0bbef1d
Update package.json
nofarb Jun 12, 2025
7a0e565
Update vite.config.js
nofarb Jun 12, 2025
33c9c3f
Update package.json
nofarb Jun 12, 2025
fc60a4e
Update ci.yml
nofarb Jun 12, 2025
644a765
Update ci.yml
nofarb Jun 12, 2025
0aecfea
Update ci.yml
nofarb Jun 12, 2025
97f82b3
Update vite.config.js
nofarb Jun 13, 2025
21b3a03
Update vite.config.js
nofarb Jun 13, 2025
5c461ee
Update package.json
nofarb Jun 13, 2025
b1e6f8d
Update package.json
nofarb Jun 13, 2025
f363e9b
Update vite.config.js
nofarb Jun 13, 2025
9956e10
Update ci.yml
nofarb Jun 13, 2025
4e7e737
Update ci.yml
nofarb Jun 13, 2025
df8ad67
Update vite.config.js
nofarb Jun 13, 2025
d3a0a0e
Update vite.config.js
nofarb Jun 13, 2025
29fd99b
Update ci.yml
nofarb Jun 13, 2025
35b9032
Update calculator.test.js
nofarb Jun 13, 2025
6c03226
Delete .circleci directory
nofarb Jun 13, 2025
6994cf8
added logic
nofarblue Jun 13, 2025
79451a5
added tests
nofarblue Jun 13, 2025
4de0ba9
added tests
nofarblue Jun 13, 2025
45c743b
added tests
nofarblue Jun 13, 2025
630785f
added bundle
nofarblue Jun 13, 2025
61cd6b4
Update README.md
nofarb Jun 13, 2025
4ca7241
Merge pull request #5 from nofarb/nofarb-patch-2
nofarb Jun 13, 2025
fe13f66
Update ci.yml
nofarb Jun 13, 2025
b25b4fb
tru sonar
nofarb Jun 13, 2025
c8496d3
Delete .github/workflows/enforce-license-compliance.yml
nofarb Jun 13, 2025
df8d857
fix sonar integration
nofarb Jun 13, 2025
ec47494
Update ci.yml
nofarb Jun 13, 2025
f477afc
fix sonar
nofarblue Jun 13, 2025
b4959ea
fix sonar
nofarblue Jun 13, 2025
1a3fa1a
fix sonar
nofarblue Jun 13, 2025
80ccc07
Add CircleCI configuration for machine inspection job
nofarb Mar 25, 2026
cf781f4
Update resource class to large.gen2 in CircleCI config
nofarb Mar 25, 2026
aba79da
Update CircleCI config for Ubuntu version and resource class
nofarb Mar 25, 2026
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
180 changes: 67 additions & 113 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,122 +1,76 @@
version: 2.1
orbs:
codecov: codecov/codecov@3


jobs:
build2:
docker:
- image: cimg/base:stable
steps:
- run:
name: Create large dummy zip file (2MB)
command: |
mkdir -p dummy-data
dd if=/dev/urandom of=dummy-data/random.bin bs=1M count=2
zip -r dummy-artifact222.zip dummy-data

- store_artifacts:
path: dummy-artifact_not_exits.zip
destination: dummy-large-file

- store_artifacts:
path: dummy-artifact222.zip

build:
docker:
- image: cimg/node:current
inspect-gen2-large:
machine:
image: ubuntu-2404:current
resource_class: medium.gen2
steps:
- checkout

- run:
name: Install dependencies
command: |
npm install --save-dev @babel/preset-env @babel/register
npm install

- run:
name: Run tests and collect coverage
command: |
npx jest --coverage
sleep 5
echo "Listing all files in the coverage directory:"
ls -R $CIRCLE_WORKING_DIRECTORY/coverage
find $CIRCLE_WORKING_DIRECTORY/coverage -type f

- store_artifacts:
path: coverage/coverage-final.json
destination: coverage-report-json

- store_artifacts:
path: coverage/lcov-report
destination: coverage-report-html

- run:
name: Create large dummy zip file (2MB)
command: |
mkdir -p dummy-data
dd if=/dev/urandom of=dummy-data/random.bin bs=1M count=2
zip -r dummy-artifact.zip dummy-data

- store_artifacts:
path: dummy-artifact.zip
destination: dummy-large-file

- run:
name: Create nested artifact structure with files at each level
command: |
base_path="/tmp/artifacts"
level1="$base_path/level1"
level2="$level1/level2"
level3="$level2/level3"

mkdir -p "$level3"

# Base64-encoded small valid PDF
pdf_base64="JVBERi0xLjQKJeLjz9MKMSAwIG9iago8PC9UeXBlIC9DYXRhbG9nL1BhZ2VzIDIgMCBSCj4+CmVuZG9iagogMiAwIG9iago8PC9UeXBlIC9QYWdlcy9Db3VudCAxL0tpZHMgWzMgMCBSXQo+PgplbmRvYmoKMyAwIG9iago8PC9UeXBlIC9QYWdlL1BhcmVudCAyIDAgUi9NZWRpYUJveCBbMCAwIDMwMCAxNDRdL0NvbnRlbnRzIDQgMCBSCj4+CmVuZG9iago0IDAgb2JqCjw8L0xlbmd0aCA0NAo+PnN0cmVhbQpCVC9GMTggVGYgMTAgMTAwIFRkIChIZWxsbyBmcm9tIHNhZmUgYmFzZTY0KSBUaiBFVAplbmRzdHJlYW0KZW5kb2JqCnhyZWYKMCA1CjAwMDAwMDAwMDAgNjU1MzUgZgowMDAwMDAwMDEwIDAwMDAwIG4KMDAwMDAwMDA2MCAwMDAwMCBuCjAwMDAwMDAxMTcgMDAwMDAgbgowMDAwMDAwMjIwIDAwMDAwIG4KdHJhaWxlcgo8PC9Sb290IDEgMCBSL1NpemUgNQo+PgpzdGFydHhyZWYKMzE1CiUlRU9GCg=="

for dir in "$level1" "$level2" "$level3"; do
mkdir -p "$dir"
echo "This is a text file in $dir" > "$dir/sample.txt"
zip -j "$dir/sample.zip" "$dir/sample.txt"
echo "$pdf_base64" | base64 -d > "$dir/sample.pdf"
done

- store_artifacts:
path: /tmp/artifacts
destination: additional-artifacts-folder

- codecov/upload

- setup_remote_docker

- run:
name: Generate Dockerfile
command: |
echo "FROM alpine" > Dockerfile
echo "WORKDIR /app" >> Dockerfile
echo "COPY coverage /app/coverage" >> Dockerfile
echo "COPY dummy-artifact.zip /app/" >> Dockerfile
echo "CMD [\"ls\", \"-lhR\", \"/app\"]" >> Dockerfile

- run:
name: Build Docker image
command: |
docker build -t $DOCKERHUB_USERNAME/circleci-artifact-demo:$CIRCLE_SHA1 .

- run:
name: Authenticate with Docker Hub
command: |
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin

- run:
name: Push Docker image
name: Inspect machine details
command: |
docker push $DOCKERHUB_USERNAME/circleci-artifact-demo:$CIRCLE_SHA1
set -euxo pipefail

echo "=== Basic OS info ==="
uname -a
cat /etc/os-release || true

echo
echo "=== CPU / memory ==="
nproc || true
lscpu || true
free -h || true

echo
echo "=== Block devices ==="
lsblk || true

echo
echo "=== DMI / virtualization hints ==="
sudo dmidecode -s system-manufacturer || true
sudo dmidecode -s system-product-name || true
sudo dmidecode -s bios-vendor || true
systemd-detect-virt || true

echo
echo "=== Hypervisor / kernel messages ==="
dmesg | egrep -i 'hypervisor|kvm|xen|nitro|google|amazon|gcp|aws' | tail -50 || true

echo
echo "=== Cloud metadata probes ==="
echo "--- AWS IMDS ---"
TOKEN=$(curl -sS -m 2 -X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 60" || true)
if [ -n "${TOKEN:-}" ]; then
echo "AWS metadata reachable"
curl -sS -m 2 -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/instance-type || true
curl -sS -m 2 -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/dynamic/instance-identity/document || true
else
echo "AWS metadata not reachable"
fi

echo
echo "--- GCP metadata ---"
if curl -sS -m 2 -H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/instance/machine-type >/dev/null 2>&1; then
echo "GCP metadata reachable"
curl -sS -m 2 -H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/instance/machine-type || true
curl -sS -m 2 -H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/instance/cpu-platform || true
curl -sS -m 2 -H "Metadata-Flavor: Google" \
http://metadata.google.internal/computeMetadata/v1/project/project-id || true
else
echo "GCP metadata not reachable"
fi

echo
echo "=== Summary ==="
echo "resource_class=large.gen2"

workflows:
version: 2.1
build-test:
inspect:
jobs:
- build
- build2
- inspect-gen2-large
93 changes: 84 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,95 @@
name: Workflow for Codecov example-javascript
name: Codecov CI with Vitest and SonarQube

on: [push, pull_request]

jobs:
run:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node 18

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: npm install
- name: Run tests and collect coverage
run: npm run test
- name: Upload coverage to Codecov

- name: Initialize clean package.json
run: |
npm init -y
npm install vitest@1.6.1 @vitest/coverage-v8@1.6.1
# Optional: only install Codecov bundle plugin if you want bundle analysis:
# npm install @codecov/vite-plugin@latest

- name: Add test & build scripts manually
run: |
jq '.scripts.test="vitest run --coverage"' package.json > tmp.json && mv tmp.json package.json
jq '.scripts.build="vite build"' package.json > tmp.json && mv tmp.json package.json

- name: Create vitest.config.ts
run: |
echo "import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
include: ['app/**/*.test.js'],
coverage: {
provider: 'v8',
reporters: ['text', 'json', 'html', 'lcov'],
reportDir: 'coverage'
},
reporters: [
'default',
['junit', { outputFile: 'junit.xml' }]
]
}
})" > vitest.config.ts

# Uncomment this block if you eventually want bundle analysis enabled again:
#
# - name: Create vite.config.js (for Codecov Bundle Analysis)
# run: |
# echo "import { defineConfig } from 'vite';
# import { codecovVitePlugin } from '@codecov/vite-plugin';
# export default defineConfig({
# plugins: [
# codecovVitePlugin({
# enableBundleAnalysis: process.env.CODECOV_TOKEN !== undefined,
# bundleName: 'example-javascript',
# uploadToken: process.env.CODECOV_TOKEN
# })
# ]
# })" > vite.config.js

# - name: Build app for bundle analysis
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
# run: npm run build

- name: Run tests with coverage
run: npm run test || true

- name: List coverage files (debugging)
run: ls -R coverage

- name: Upload code coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_ORG_TOKEN }}

- name: SonarQube Scan
uses: SonarSource/sonarqube-scan-action@v5

Check warning on line 87 in .github/workflows/ci.yml

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

.github/workflows/ci.yml#L87

An action sourced from a third-party repository on GitHub is not pinned to a full length commit SHA. Pinning an action to a full length commit SHA is currently the only way to use an action as an immutable release.
with:
args: >
-Dsonar.projectKey=nofarb_example-javascript
-Dsonar.organization=nofarb
-Dsonar.verbose=true
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

14 changes: 0 additions & 14 deletions .github/workflows/enforce-license-compliance.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ For more information, please see the links below.
- [Community Boards](https://community.codecov.io)
- [Support](https://codecov.io/support)
- [Documentation](https://docs.codecov.io)


## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fcodecov%2Fexample-javascript.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fcodecov%2Fexample-javascript?ref=badge_large)
File renamed without changes.
16 changes: 2 additions & 14 deletions app/calculator.test.js → app/core/calculator.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect, test } from '@jest/globals';
import { expect, test } from 'vitest';

import {
add,
Expand All @@ -25,17 +25,5 @@ test('subtract function', () => {
});

test('multiply function', () => {
expect(multiply(1, 2)).toBe(2.0);
expect(multiply(1.0, 2.0)).toBe(2.0);
expect(multiply(0, 2.0)).toBe(0.0);
expect(multiply(2.0, 0)).toBe(0.0);
expect(multiply(-4, 2.0)).toBe(-8.0);
});

test('divide function', () => {
expect(divide(1, 2)).toBe(0.5);
expect(divide(1.0, 2.0)).toBe(0.5);
expect(divide(0, 2.0)).toBe(0);
expect(divide(-4, 2.0)).toBe(-2.0);
// expect(divide(2.0, 0)).toBe('Cannot divide by 0');
expect(multiply(1, 2)).toBe(2);
});
13 changes: 13 additions & 0 deletions app/utils/mathUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export function square(x) {
return x * x;
}

export function cube(x) {
return x * x * x;
}

export function factorial(n) {
if (n === 0) return 1;
return n * factorial(n - 1);
}

14 changes: 14 additions & 0 deletions app/utils/mathUtils.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from 'vitest';
import { square, cube, factorial } from './mathUtils';

test('square function', () => {
expect(square(2)).toBe(4);
expect(square(-3)).toBe(9);
});

test('cube function', () => {
expect(cube(2)).toBe(8);
expect(cube(-3)).toBe(-27);
});

// Intentionally leave factorial untested for now
Empty file added index.html
Empty file.
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { square } from './app/mathUtils.js';
console.log(square(5));
Loading
Loading