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

✨ add tests and workflow to run the tests and publish output #72

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
105 changes: 105 additions & 0 deletions .github/workflows/local-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Local CI

on: ["push", "pull_request"]

jobs:
test:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Setup Homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Upgrade podman
run: |
sudo apt-get install -y ansible
export DEB=$(curl -s https://passt.top/builds/latest/x86_64/ | grep deb | awk -F '"' '{ print $4}')
sudo ansible -m apt -a deb=https://passt.top/builds/latest/x86_64/${DEB} localhost
sudo apt-get remove podman crun
brew install crun podman

- uses: actions/checkout@v3

- name: Run kantra test
id: kantra-test
run: |
podman cp $(podman create --name kantra-download quay.io/konveyor/kantra:latest):/usr/local/bin/kantra .
podman rm kantra-download
./kantra test ./default/generated/ | tee output.log || true
tail -n5 output.log > message.md
msg=$(grep -E '.*Rules Summary:' message.md -A1)
tests_pass_rate=$(grep -E '.*Rules Summary:' message.md | sed -E 's| *Rules Summary: *(.*)|\1|' | sed -E 's|.*?:||')
tcs_pass_rate=$(grep -E '.*Test Cases Summary:' message.md | sed -E 's| *Test Cases Summary: *(.*)|\1|' | sed -E 's|.*?:||')

echo 'msg<<EOF' >> $GITHUB_OUTPUT
echo ${msg} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

echo 'tcs_pass_rate<<EOF' >> $GITHUB_OUTPUT
echo ${tcs_pass_rate} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

echo 'tests_pass_rate<<EOF' >> $GITHUB_OUTPUT
echo ${tests_pass_rate} >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT

- name: Comment on the PR
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@v6
with:
script: |
const issue_number = context.payload.pull_request.number;
const owner = context.repo.owner;
const repo = context.repo.repo;
const body = `${{ steps.kantra-test.outputs.msg }}`;

const comments = await github.rest.issues.listComments({
owner,
repo,
issue_number
});

const botComment = comments.data.find(comment =>
comment.user.login === 'github-actions[bot]');

if (botComment) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: botComment.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body
});
}
github-token: ${{ secrets.GITHUB_TOKEN }}
debug: true

- name: Update tests badge
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/[email protected]
with:
NAME: konveyor-rulesets-tests-rate
LABEL: Test Status
STATUS: ${{ steps.kantra-test.outputs.tests_pass_rate }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Update test case badge
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: RubbaBoy/[email protected]
with:
NAME: konveyor-rulesets-tcs-rate
LABEL: Test Case Status
STATUS: ${{ steps.kantra-test.outputs.tcs_pass_rate }}
COLOR: blue
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

![](https://byob.yarr.is/konveyor/rulesets/konveyor-rulesets-tests-rate)

![](https://byob.yarr.is/konveyor/rulesets/konveyor-rulesets-tcs-rate)

# Overview
This repository is a future home for Konveyor's static code analysis Rulesets. It is intended to contain future rules to aid static code analysis as well as issues shared by subject matter experts to aid creation of richer Rulesets.
* Intended for [Rules](https://github.com/konveyor/analyzer-lsp/blob/main/docs/rules.md) compatible with [konveyor/analyzer-lsp](https://github.com/konveyor/analyzer-lsp)
Expand Down
37 changes: 37 additions & 0 deletions default/generated/azure/tests/01-azure-aws-config.windup.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
rulesPath: ../01-azure-aws-config.windup.yaml
providers:
- name: java
dataPath: ./data/01-azure-aws-config
- name: builtin
dataPath: ./data/01-azure-aws-config
tests:
- ruleID: azure-aws-config-credential-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 8
messageMatches: The application contains AWS credential configuration
- ruleID: azure-aws-config-region-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: The application contains AWS region configuration
- ruleID: azure-aws-config-s3-03000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: The application contains AWS S3 configuration
- ruleID: azure-aws-config-sqs-04000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: The application contains Amazon Simple Queue Service configuration
- ruleID: azure-aws-config-secret-manager-05000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: The application contains AWS Secrets Manager configuration.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
rulesPath: ../02-azure-file-system.windup.yaml
providers:
- name: java
dataPath: ./data/02-azure-file-system
- name: builtin
dataPath: ./data/02-azure-file-system
tests:
- ruleID: azure-file-system-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 5
messageMatches: The application uses Java APIs to read/write from the file system.
- ruleID: azure-file-system-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: Relative path found.
- ruleID: azure-file-system-03000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: Home path found.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rulesPath: ../03-azure-java-version.windup.yaml
providers:
- name: java
dataPath: ./data/03-azure-java-version
- name: builtin
dataPath: ./data/03-azure-java-version
tests:
- ruleID: azure-java-version-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: The application is using non-LTS version Java.
- ruleID: azure-java-version-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: The application is using Java version lower than JAVA_8.
14 changes: 14 additions & 0 deletions default/generated/azure/tests/04-azure-logging.windup.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rulesPath: ../04-azure-logging.windup.yaml
providers:
- name: java
dataPath: ./data/04-azure-logging
- name: builtin
dataPath: ./data/04-azure-logging
tests:
- ruleID: azure-logging-0000
testCases:
- name: tc-1
hasIncidents:
atLeast: 12
messageMatches: Logging to the file system is not recommended when running applications
in the cloud.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
rulesPath: ../05-azure-os-specific.windup.yaml
providers:
- name: java
dataPath: ./data/05-azure-os-specific
- name: builtin
dataPath: ./data/05-azure-os-specific
tests:
- ruleID: azure-os-specific-00001
testCases:
- name: tc-1
hasIncidents:
atLeast: 4
messageMatches: This file system path is Microsoft Windows platform dependent
- name: tc-2
hasIncidents:
atLeast: 4
messageMatches: This file system path is Microsoft Windows platform dependent.*
- ruleID: azure-os-specific-00002
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: This Dynamic-Link Library is Microsoft Windows platform dependent
- name: tc-2
hasIncidents:
atLeast: 1
messageMatches: This Dynamic-Link Library is Microsoft Windows platform dependent.*
13 changes: 13 additions & 0 deletions default/generated/azure/tests/06-azure-password.windup.test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rulesPath: ../06-azure-password.windup.yaml
providers:
- name: java
dataPath: ./data/06-azure-password
- name: builtin
dataPath: ./data/06-azure-password
tests:
- ruleID: azure-password-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 7
messageMatches: Password found in configuration file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rulesPath: ../07-eap-to-azure-appservice-certificates.windup.yaml
providers:
- name: java
dataPath: ./data/07-eap-to-azure-appservice-certificates
- name: builtin
dataPath: ./data/07-eap-to-azure-appservice-certificates
tests:
- ruleID: eap-to-azure-appservice-certificates-001
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: Azure - The application loads certificates into a KeyStor.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rulesPath: ../08-eap-to-azure-appservice-datasource-driver.windup.yaml
providers:
- name: java
dataPath: ./data/08-eap-to-azure-appservice-datasource-driver
- name: builtin
dataPath: ./data/08-eap-to-azure-appservice-datasource-driver
tests:
- ruleID: eap-to-azure-appservice-datasource-driver-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 17
messageMatches: A datasource driver was found in a configuration fil.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rulesPath: ../09-eap-to-azure-appservice-environment-variables.windup.yaml
providers:
- name: java
dataPath: ./data/09-eap-to-azure-appservice-environment-variables
- name: builtin
dataPath: ./data/09-eap-to-azure-appservice-environment-variables
tests:
- ruleID: eap-to-azure-appservice-environment-variables-001
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: App Service - The application reads environment variable.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
rulesPath: ../10-eap-to-azure-appservice-pom.windup.yaml
providers:
- name: java
dataPath: ./data/10-eap-to-azure-appservice-pom
- name: builtin
dataPath: ./data/10-eap-to-azure-appservice-pom
tests:
- ruleID: eap-to-azure-appservice-pom-001
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: Get started with JBoss EAP on App Servic.*
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
rulesPath: ../11-spring-boot-to-azure-cache.windup.yaml
providers:
- name: java
dataPath: ./data/11-spring-boot-to-azure-cache
- name: builtin
dataPath: ./data/11-spring-boot-to-azure-cache
tests:
- ruleID: spring-boot-to-azure-cache-redis-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 4
messageMatches: The application uses a Redis Cache.
- ruleID: spring-boot-to-azure-cache-redis-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 4
messageMatches: Redis Cache connection string, username, or password used in
this application
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
rulesPath: ../12-spring-boot-to-azure-config-server.windup.yaml
providers:
- name: java
dataPath: ./data/12-spring-boot-to-azure-config-server
- name: builtin
dataPath: ./data/12-spring-boot-to-azure-config-server
tests:
- ruleID: spring-boot-to-azure-config-server-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 3
messageMatches: The application uses a Spring Cloud Config Server connection
string
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
rulesPath: ../13-spring-boot-to-azure-database.windup.yaml
providers:
- name: java
dataPath: ./data/13-spring-boot-to-azure-database
- name: builtin
dataPath: ./data/13-spring-boot-to-azure-database
tests:
- ruleID: spring-boot-to-azure-database-jdbc-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: The application uses a JDBC connection string
- ruleID: spring-boot-to-azure-database-mongodb-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: The application uses a MongoDB connection string
- ruleID: spring-boot-to-azure-database-r2dbc-03000
testCases:
- name: tc-1
hasIncidents:
atLeast: 1
messageMatches: The application uses a R2DBC connection string
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
rulesPath: ../14-spring-boot-to-azure-eureka.windup.yaml
providers:
- name: java
dataPath: ./data/14-spring-boot-to-azure-eureka
- name: builtin
dataPath: ./data/14-spring-boot-to-azure-eureka
tests:
- ruleID: spring-boot-to-azure-eureka-01000
testCases:
- name: tc-1
hasIncidents:
atLeast: 3
messageMatches: The application uses Eureka.
- ruleID: spring-boot-to-azure-eureka-02000
testCases:
- name: tc-1
hasIncidents:
atLeast: 2
messageMatches: The application uses an eureka connection string.
Loading
Loading