Skip to content

Commit

Permalink
Use snapshot build in functional tests (#643)
Browse files Browse the repository at this point in the history
### What's done:
* Use snapshot build in CLI run
* Removed functional tests workflow
* Do not use github packages
* Run all tests on different platforms
  • Loading branch information
petertrr authored Dec 18, 2020
1 parent 6e60194 commit 7237a31
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 144 deletions.
93 changes: 91 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
pull_request

jobs:
test:
name: Unit Test
build_and_test_with_code_coverage:
name: Build, test and upload code coverage
runs-on: ubuntu-18.04

steps:
# actions/checkout v1.* is needed for correct codecov upload, see github issues for details
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
Expand All @@ -31,3 +32,91 @@ jobs:
file: ./*/target/site/jacoco/jacoco.xml
flags: unittests
fail_ci_if_error: true # optional (default = false)
- name: Upload diktat jar
uses: actions/upload-artifact@v2
with:
name: diktat-ruleset
path: diktat-ruleset/target/diktat-*.jar
# no need to store artifact longer, it is used only by dependant jobs
retention-days: 1

run_diktat_from_CLI:
name: Run diktat via CLI
runs-on: ${{ matrix.os }}
needs: build_and_test_with_code_coverage
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]

steps:
- uses: actions/checkout@v2.3.3

- name: Setup environment variables
run: |
cat pom.xml | grep "<version>.*</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
shell: bash

- name: Download diktat jar
uses: actions/download-artifact@v2
with:
name: diktat-ruleset

- 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: |
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

build_and_test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- uses: actions/checkout@v2.3.3
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-build-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-build-
- name: Maven Install
if: ${{ runner.os == 'Linux' || runner.os == 'macOS' }}
run: |
mvn -B clean install
shell: bash

- name: Maven Install on windows
if: runner.os == 'Windows'
run: |
mvn -B clean install
shell: cmd
141 changes: 0 additions & 141 deletions .github/workflows/functional_tests.yml

This file was deleted.

6 changes: 5 additions & 1 deletion examples/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>

<properties>
<diktat.version>0.1.7</diktat.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.cqfn.diktat</groupId>
<artifactId>diktat-maven-plugin</artifactId>
<version>0.1.7</version>
<version>${diktat.version}</version>
<configuration>
<diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
<inputs>
Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<module>diktat-gradle-plugin</module>
</modules>

<!-- Even though deployment is handled by nexus plugin, this section is required for it's operation -->
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
Expand Down Expand Up @@ -200,6 +201,11 @@
<artifactId>maven-plugin-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
Expand Down

0 comments on commit 7237a31

Please sign in to comment.