Skip to content
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

chore: add unit tests, integration tests, coverage and documentation #32

Merged
merged 16 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI Checks
on:
push:
pull_request:

jobs:
lint-and-test:
name: Lint and Test
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Run lint
run: npm run lint

- name: Run test
run: npm run test

check-dist:
name: Check Distribution
runs-on: ubuntu-latest

env:
BUNDLE_FILE: "dist/index.js"
BUNDLE_COMMAND: "npm run bundle"

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
registry-url: 'https://npm.pkg.github.com'
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: npm ci

- name: Verify Latest Bundle
uses: redhat-actions/common/bundle-verifier@v1
with:
bundle_file: ${{ env.BUNDLE_FILE }}
bundle_command: ${{ env.BUNDLE_COMMAND }}
61 changes: 61 additions & 0 deletions .github/workflows/scan_docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Scan Docker project
on:
push:
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
# Test once with explicit manifest_file, and once without
manifest_file: ["Dockerfile", ""]
include:
- index: 1
manifest_file: "Dockerfile"
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: Analyse Docker project
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 20
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '20'

- name: Install syft
run: |
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin v1.7.0

- name: Install skopeo
run: |
sudo apt-get update
sudo apt-get install -y skopeo

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/docker
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
53 changes: 53 additions & 0 deletions .github/workflows/scan_go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Scan Golang project
on:
push:
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
# Test once with explicit manifest_file, and once without
manifest_file: ["go.mod", ""]
include:
- index: 1
manifest_file: "go.mod"
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: Analyse Golang project
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.22'

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/golang
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
61 changes: 61 additions & 0 deletions .github/workflows/scan_gradle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Scan Gradle project
on:
push:
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
# Test once with explicit manifest_file, and once without
manifest_file: ["build.gradle", ""]
include:
- index: 1
manifest_file: "build.gradle"
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: Analyse Gradle project
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '20'

- name: Install gradle dependencies
if: matrix.os == 'windows-latest'
run: |
cd manifests/gradle/
gradle dependencies
cd ../../

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/gradle
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
54 changes: 54 additions & 0 deletions .github/workflows/scan_maven.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Scan Maven project
on:
push:
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
# Test once with explicit manifest_file, and once without
manifest_file: ["pom.xml", ""]
include:
- index: 1
manifest_file: "pom.xml"
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: Analyse Maven project
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '20'

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/maven
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
53 changes: 53 additions & 0 deletions .github/workflows/scan_npm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Scan Npm project
on:
push:
workflow_dispatch:

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
# Test once with explicit manifest_file, and once without
manifest_file: ["package.json", ""]
include:
- index: 1
manifest_file: "package.json"
- index: 2
manifest_file: ""
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
name: Analyse Npm project
steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: RHDA Scan
id: rhda_scan
uses: RHEcosystemAppEng/rhda-github-action@chore/unit-tests
with:
manifest_directory: manifests/npm
manifest_file: ${{ matrix.manifest_file }}
artifact_filename: ${{ matrix.os }}${{ matrix.index }}-rhda-report
fail_on: never

- name: Print JSON analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_json }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_json }}
shell: bash

- name: Print SARIF analysis report
if: ${{ always() && steps.rhda_scan.outputs.rhda_report_sarif }}
run: cat ${{ steps.rhda_scan.outputs.rhda_report_sarif }}
shell: bash

- name: Print Artifact ID
run: echo ${{ steps.rhda_scan.outputs.artifact_id }}
Loading
Loading