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

Run functional tests on different OS #633

Merged
merged 21 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from 20 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
2 changes: 1 addition & 1 deletion .github/workflows/diktat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
diktat_check:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/diktat_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ env:

jobs:
diktat_snapshot_check:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- uses: actions/[email protected]
Expand Down
111 changes: 86 additions & 25 deletions .github/workflows/functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,74 +7,135 @@ on:
branches: [ master ]

env:
DIKTAT_VERSION: 0.1.7
KTLINT_VERSION: 0.39.0
GRADLE_OPTS: -Dorg.gradle.daemon=false # to speed up gradle run

jobs:
run-functional-tests:
runs-on: ubuntu-latest
run_diktat_from_CLI:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use ubuntu-latest, but previously we were using ubuntu-20.04?

Copy link
Member Author

@petertrr petertrr Dec 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't matter much, currently ubuntu-latest is 18.04, but github has already announced it will be changed to 20.04 soon. I thought that since I introduce other OS here, it will be easier to just use latest tag and not manage specific versions for all environments. And since diktat is a JVM application, it should run on all recent distros.


steps:
- uses: actions/[email protected]

- name: Setup environment
- name: Setup environment variables
run: |
cat pom.xml | grep "<diktat-check.version>.*</diktat-check.version>" | head -1 |awk -F'[><]' '{ENVIRON[DIKTAT_VERSION]=$3 ; print ENVIRON[DIKTAT_VERSION]}'
cat pom.xml | grep "<ktlint.version>.*</ktlint.version>" | head -1 |awk -F'[><]' '{ENVIRON[KTLINT_VERSION]=$3 ; print ENVIRON[KTLINT_VERSION]}'
curl -sSLO https://github.com/pinterest/ktlint/releases/download/$KTLINT_VERSION/ktlint && chmod a+x ktlint
curl -sSLO https://github.com/cqfn/diKTat/releases/download/v$DIKTAT_VERSION/diktat-$DIKTAT_VERSION.jar
cat pom.xml | grep "<diktat-check.version>.*</diktat-check.version>" | head -1 | awk -F'[><]' '{ printf "DIKTAT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
cat pom.xml | grep "<ktlint.version>.*</ktlint.version>" | head -1 | awk -F'[><]' '{ printf "KTLINT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
shell: bash

- name: Setup environment
run: |
curl -sSLO https://github.com/pinterest/ktlint/releases/download/${{ env.KTLINT_VERSION }}/ktlint && chmod a+x ktlint
curl -sSLO https://github.com/cqfn/diKTat/releases/download/v${{ env.DIKTAT_VERSION }}/diktat-${{ env.DIKTAT_VERSION }}.jar
shell: bash

- name: Copy diktat-analysis.yml from release
run: |
unzip -q -d tmp diktat-$DIKTAT_VERSION.jar
unzip -q -d tmp diktat-${{ env.DIKTAT_VERSION }}.jar
DIKTAT_CONFIG=diktat-analysis.yml
md5sum $DIKTAT_CONFIG
find tmp -name $DIKTAT_CONFIG -exec cp "{}" . \;
md5sum $DIKTAT_CONFIG
shell: bash

- name: Run diKTat from cli
continue-on-error: true
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: |
./ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar "examples/maven/src/main/kotlin/Test.kt" &> out
shell: bash

- name: Run diKTat from cli on windows
continue-on-error: true
if: runner.os == 'Windows'
run: |
./ktlint -R diktat-$DIKTAT_VERSION.jar "examples/maven/src/main/kotlin/Test.kt" &> out
java.exe -jar ktlint -R diktat-${{ env.DIKTAT_VERSION }}.jar "examples/maven/src/main/kotlin/Test.kt" > out.txt 2>&1
shell: cmd

- name: Check output
id: cli-check
run: |
if [ -f out.txt ]; then mv out.txt out; fi
cat out
grep -E "\[VARIABLE_NAME_INCORRECT_FORMAT\]" out
shell: bash

- name: Run diKTat from gradle kotlin DSL
continue-on-error: true
working-directory: ./examples/gradle-kotlin-dsl
run_diktat_from_gradle:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
dir: [ ./examples/gradle-kotlin-dsl, ./examples/gradle-groovy-dsl ]
steps:
- uses: actions/[email protected]

- name: Setup environment variables
run: |
gradle diktatCheck &> out
cat pom.xml | grep "<diktat-check.version>.*</diktat-check.version>" | head -1 | awk -F'[><]' '{ printf "DIKTAT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
shell: bash

- name: Check gradle from kotlin DSL
working-directory: ./examples/gradle-kotlin-dsl
- name: Setup environment
run: |
cat out
grep -E "\[VARIABLE_NAME_INCORRECT_FORMAT\]" out
curl -sSLO https://github.com/cqfn/diKTat/releases/download/v${{ env.DIKTAT_VERSION }}/diktat-${{ env.DIKTAT_VERSION }}.jar
unzip -q -d tmp diktat-${{ env.DIKTAT_VERSION }}.jar
DIKTAT_CONFIG=diktat-analysis.yml
find tmp -name $DIKTAT_CONFIG -exec cp "{}" . \;
shell: bash

- name: Run diKTat from gradle groovy DSL
- name: Run diKTat from gradle
continue-on-error: true
working-directory: ./examples/gradle-groovy-dsl
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
working-directory: ${{ matrix.dir }}
run: |
gradle diktatCheck &> out
shell: bash

- name: Run diKTat from gradle on windows
continue-on-error: true
if: runner.os == 'Windows'
working-directory: ${{ matrix.dir }}
run: |
gradle.exe diktatCheck > out.txt 2>&1
shell: cmd

- name: Check gradle from groovy DSL
working-directory: ./examples/gradle-groovy-dsl
- name: Check gradle
working-directory: ${{ matrix.dir }}
run: |
if [ -f out.txt ]; then mv out.txt out; fi
cat out
grep -E "\[VARIABLE_NAME_INCORRECT_FORMAT\]" out
shell: bash

run_diktat_from_maven:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/[email protected]

- name: Setup environment variables
run: |
cat pom.xml | grep "<diktat-check.version>.*</diktat-check.version>" | head -1 | awk -F'[><]' '{ printf "DIKTAT_VERSION=%s\n",$3 }' >> $GITHUB_ENV
shell: bash

- name: Setup environment
run: |
curl -sSLO https://github.com/cqfn/diKTat/releases/download/v${{ env.DIKTAT_VERSION }}/diktat-${{ env.DIKTAT_VERSION }}.jar
unzip -q -d tmp diktat-${{ env.DIKTAT_VERSION }}.jar
DIKTAT_CONFIG=diktat-analysis.yml
find tmp -name $DIKTAT_CONFIG -exec cp "{}" . \;
shell: bash

- name: Run diKTat from maven
working-directory: ./examples/maven
continue-on-error: true
run: mvn -B diktat:check &> out
shell: bash

- name: Check maven
working-directory: ./examples/maven
run: |
cat out
grep -E "\[VARIABLE_NAME_INCORRECT_FORMAT\]" out
shell: bash