From 5d7a643ff9b4f583ab29e7fa5bd09e8d1a831b22 Mon Sep 17 00:00:00 2001 From: Peter Kofler Date: Sat, 8 Jun 2024 20:48:39 +0200 Subject: [PATCH 1/3] Make tests on master similar to working tests but tests on master should fail. --- .gitignore | 1 + .../java/dojo/liftpasspricing/PricesTest.java | 15 +++++++-------- .../java/dojo/liftpasspricing/PricesTest.java | 13 +++++++------ javascript/test/prices.test.js | 9 ++++----- python/test/test_prices.py | 2 +- typescript/package.json | 2 -- typescript/test/prices.spec.ts | 11 +++++------ 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 090a1f02..dfd0866c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea .DS_Store +.project diff --git a/java-simple/src/test/java/dojo/liftpasspricing/PricesTest.java b/java-simple/src/test/java/dojo/liftpasspricing/PricesTest.java index de3bac2c..73fe90d4 100644 --- a/java-simple/src/test/java/dojo/liftpasspricing/PricesTest.java +++ b/java-simple/src/test/java/dojo/liftpasspricing/PricesTest.java @@ -1,18 +1,17 @@ package dojo.liftpasspricing; -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.sql.Connection; -import java.sql.SQLException; - +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; - -import io.restassured.RestAssured; -import io.restassured.path.json.JsonPath; import spark.Spark; +import java.sql.Connection; +import java.sql.SQLException; + +import static org.junit.jupiter.api.Assertions.assertEquals; + public class PricesTest { private static Connection connection; diff --git a/java/src/test/java/dojo/liftpasspricing/PricesTest.java b/java/src/test/java/dojo/liftpasspricing/PricesTest.java index edec9c5d..f6b266e1 100644 --- a/java/src/test/java/dojo/liftpasspricing/PricesTest.java +++ b/java/src/test/java/dojo/liftpasspricing/PricesTest.java @@ -1,15 +1,16 @@ package dojo.liftpasspricing; -import static org.junit.jupiter.api.Assertions.assertEquals; +import io.restassured.RestAssured; +import io.restassured.path.json.JsonPath; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import spark.Spark; import java.sql.Connection; import java.sql.SQLException; -import org.junit.jupiter.api.*; - -import io.restassured.RestAssured; -import io.restassured.path.json.JsonPath; -import spark.Spark; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PricesTest { diff --git a/javascript/test/prices.test.js b/javascript/test/prices.test.js index f606426b..9bc375f4 100644 --- a/javascript/test/prices.test.js +++ b/javascript/test/prices.test.js @@ -14,10 +14,9 @@ describe('prices', () => { }); it('does something', async () => { - const response = await request(app) - .get('/prices?type=1jour') + const {body} = await request(app) + .get('/prices') - const expectedResult = {cost: 123} // change this to make the test pass - expect(response.body).toEqual(expectedResult) - }) + expect(body.putSomethingHere).toEqual(35) + }) }) \ No newline at end of file diff --git a/python/test/test_prices.py b/python/test/test_prices.py index 4b5a4c67..e7e47ff8 100644 --- a/python/test/test_prices.py +++ b/python/test/test_prices.py @@ -37,4 +37,4 @@ def lift_pass_pricing_app(): def test_something(lift_pass_pricing_app): response = requests.get(lift_pass_pricing_app + "/prices", params={'type': '1jour'}) - assert response.json() == {'cost': 35} + assert response.json() == {'putSomethingHere': 35} diff --git a/typescript/package.json b/typescript/package.json index b07d41eb..ef9bbe6a 100644 --- a/typescript/package.json +++ b/typescript/package.json @@ -18,11 +18,9 @@ "@types/express": "^4.17.1", "@types/mocha": "^5.2.6", "@types/supertest": "^2.0.7", - "@types/supertest-as-promised": "^2.0.37", "chai": "^4.2.0", "mocha": "^6.1.2", "supertest": "^4.0.2", - "supertest-as-promised": "^4.0.2", "ts-node": "^8.0.3", "typescript": "^4.8.4" } diff --git a/typescript/test/prices.spec.ts b/typescript/test/prices.spec.ts index 2eb5d86f..cf76225d 100644 --- a/typescript/test/prices.spec.ts +++ b/typescript/test/prices.spec.ts @@ -1,13 +1,13 @@ -import {assert, expect} from 'chai'; -import request from 'supertest-as-promised'; import {createApp} from "../src/prices" +import request from 'supertest' +import {expect} from 'chai'; describe('prices', () => { let app, connection beforeEach(async () => { - ({app, connection} = await createApp()); + ({app, connection} = await createApp()) }); afterEach(async () => { @@ -16,11 +16,10 @@ describe('prices', () => { it('does something', async () => { - const response = await request(app) + const {body} = await request(app) .get('/prices?type=1jour') - var expectedResult = {cost: 35} // change this to make the test pass - expect(response.body).deep.equal(expectedResult) + expect(body.putSomethingHere).equal(35) }); }); From e1fef1ff8140e683780154178534144e012c7a23 Mon Sep 17 00:00:00 2001 From: Peter Kofler Date: Sat, 8 Jun 2024 20:49:25 +0200 Subject: [PATCH 2/3] Add all build actions to build master branch too. --- .github/workflows/csharp-build.yml | 75 +++++++++++++++++++++++ .github/workflows/csharp-simple-build.yml | 69 +++++++++++++++++++++ .github/workflows/java-build.yml | 66 ++++++++++++++++++++ .github/workflows/java-simple-build.yml | 66 ++++++++++++++++++++ .github/workflows/javascript-build.yml | 49 +++++++++++++++ .github/workflows/php-simple-build.yml | 42 +++++++++++++ .github/workflows/python-build.yml | 57 +++++++++++++++++ .github/workflows/scala-build.yml | 40 ++++++++++++ .github/workflows/typescript-build.yml | 51 +++++++++++++++ 9 files changed, 515 insertions(+) create mode 100644 .github/workflows/csharp-build.yml create mode 100644 .github/workflows/csharp-simple-build.yml create mode 100644 .github/workflows/java-build.yml create mode 100644 .github/workflows/java-simple-build.yml create mode 100644 .github/workflows/javascript-build.yml create mode 100644 .github/workflows/php-simple-build.yml create mode 100644 .github/workflows/python-build.yml create mode 100644 .github/workflows/scala-build.yml create mode 100644 .github/workflows/typescript-build.yml diff --git a/.github/workflows/csharp-build.yml b/.github/workflows/csharp-build.yml new file mode 100644 index 00000000..ca73b77e --- /dev/null +++ b/.github/workflows/csharp-build.yml @@ -0,0 +1,75 @@ +# Workflow to build and test the csharp version +name: csharp-build + +# Controls when the action will run. +on: + push: + paths: + - 'csharp/**' + - '**/csharp-build.yml' + pull_request: + paths: + - 'csharp/**' + - '**/csharp-build.yml' + +defaults: + run: + working-directory: ./csharp + +jobs: + build: + + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + permissions: + id-token: write + contents: read + statuses: write + checks: write + + steps: + - name: checkout source + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ../database/initDatabase.sql + + - name: Setup dotnet build + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x + + - name: use nuget cache + uses: actions/cache@v2 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + + - name: install dependencies + run: dotnet restore + + - name: build solution + run: dotnet build + + - name: run unit tests + run: dotnet test --logger "trx;logfilename=${GITHUB_WORKSPACE}/unit_test_results.xml" + + - name: Test Reporter + uses: dorny/test-reporter@v1.5.0 + if: always() + with: + name: publish test results + + path: "unit_test_results.xml" + reporter: dotnet-trx + fail-on-error: false diff --git a/.github/workflows/csharp-simple-build.yml b/.github/workflows/csharp-simple-build.yml new file mode 100644 index 00000000..be444360 --- /dev/null +++ b/.github/workflows/csharp-simple-build.yml @@ -0,0 +1,69 @@ +# Workflow to build and test the csharp version +name: csharp-simple-build + +# Controls when the action will run. +on: + push: + paths: + - 'csharp-simple/**' + - '**/csharp-simple-build.yml' + pull_request: + paths: + - 'csharp-simple/**' + - '**/csharp-simple-build.yml' + +defaults: + run: + working-directory: ./csharp-simple + +jobs: + build: + + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: checkout source + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ../database/initDatabase.sql + + - name: Setup dotnet build + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 3.1.x + + - name: use nuget cache + uses: actions/cache@v2 + with: + path: ~/.nuget/packages + key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-nuget + + - name: install dependencies + run: dotnet restore + + - name: build solution + run: dotnet build + + - name: run unit tests + run: dotnet test --logger "trx;logfilename=${GITHUB_WORKSPACE}/unit_test_results.xml" + + - name: Test Reporter + uses: dorny/test-reporter@v1.4.3 + if: always() + with: + name: publish test results + + path: "unit_test_results.xml" + reporter: dotnet-trx + fail-on-error: false diff --git a/.github/workflows/java-build.yml b/.github/workflows/java-build.yml new file mode 100644 index 00000000..0b6fc939 --- /dev/null +++ b/.github/workflows/java-build.yml @@ -0,0 +1,66 @@ +# Workflow to build and test the java version + +name: java-build + +env: + PROJECT_DIR: java + +# Controls when the action will run. +on: + push: + paths: + - 'java/**' + - '**/java-build.yml' + + pull_request: + paths: + - 'java/**' + - '**/java-build.yml' + +jobs: + # This workflow contains a single job called "build" + build: + defaults: + run: + working-directory: ./${{ env.PROJECT_DIR }} + + # The type of runner that the job will run on + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('./pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build and test + run: | + mvn -B clean install + + - name: Publish Unit Tests + uses: EnricoMi/publish-unit-test-result-action@v1.17 + if: always() + with: + files: ./${{ env.PROJECT_DIR }}/target/**/*.xml diff --git a/.github/workflows/java-simple-build.yml b/.github/workflows/java-simple-build.yml new file mode 100644 index 00000000..3c9889cd --- /dev/null +++ b/.github/workflows/java-simple-build.yml @@ -0,0 +1,66 @@ +# Workflow to build and test the java-simple version + +name: java-simple-build + +env: + PROJECT_DIR: java-simple + +# Controls when the action will run. +on: + push: + paths: + - 'java-simple/**' + - '**/java-simple-build.yml' + + pull_request: + paths: + - 'java-simple/**' + - '**/java-simple-build.yml' + +jobs: + # This workflow contains a single job called "build" + build: + defaults: + run: + working-directory: ./${{ env.PROJECT_DIR }} + + # The type of runner that the job will run on + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Set up Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + + - name: Cache Maven packages + uses: actions/cache@v2 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ hashFiles('./pom.xml') }} + restore-keys: ${{ runner.os }}-m2 + + - name: Build and test + run: | + mvn -B clean install + + - name: Publish Unit Tests + uses: EnricoMi/publish-unit-test-result-action@v1.17 + if: always() + with: + files: ./${{ env.PROJECT_DIR }}/target/**/*.xml diff --git a/.github/workflows/javascript-build.yml b/.github/workflows/javascript-build.yml new file mode 100644 index 00000000..7261484c --- /dev/null +++ b/.github/workflows/javascript-build.yml @@ -0,0 +1,49 @@ +name: javascript-buld + +env: + PROJECT_DIR: javascript + +on: + push: + paths: + - 'javascript/**' + - '.github/workflows/javascript-build.yml' + pull_request: + paths: + - 'typescript/**' + - '.github/workflows/javascript-build.yml' + +jobs: + build: + defaults: + run: + working-directory: ./${{ env.PROJECT_DIR }} + + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 15.x + + - name: Set up dependencies + run: npm install + + - name: Test + run: npm test + diff --git a/.github/workflows/php-simple-build.yml b/.github/workflows/php-simple-build.yml new file mode 100644 index 00000000..a4b85604 --- /dev/null +++ b/.github/workflows/php-simple-build.yml @@ -0,0 +1,42 @@ +name: php-simple-build + +on: + push: + paths: + - 'php-simple/**' + - '.github/workflows/php-simple-build.yml' + pull_request: + paths: + - 'php-simple/**' + - '.github/workflows/php-simple-build.yml' + +jobs: + build: + runs-on: ubuntu-latest + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.3 + + - name: Set up dependencies + working-directory: php-simple + run: composer install + + - name: Test + working-directory: php-simple + run: ./vendor/bin/phpunit diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml new file mode 100644 index 00000000..f98edc6c --- /dev/null +++ b/.github/workflows/python-build.yml @@ -0,0 +1,57 @@ +name: python-build + +env: + PROJECT_DIR: python + +on: + push: + paths: + - 'python/**' + - '.github/workflows/python-build.yml' + pull_request: + paths: + - 'python/**' + - '.github/workflows/python-build.yml' + +jobs: + build: + defaults: + run: + working-directory: ./${{ env.PROJECT_DIR }} + + runs-on: ubuntu-22.04 + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} version + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Install MySQL odbc driver + run: | + wget https://repo.mysql.com/apt/ubuntu/pool/mysql-8.0/m/mysql-community/mysql-community-client-plugins_8.0.32-1ubuntu22.04_amd64.deb + sudo dpkg -i mysql-community-client-plugins_8.0.32-1ubuntu22.04_amd64.deb + wget https://dev.mysql.com/get/Downloads/Connector-ODBC/8.0/mysql-connector-odbc_8.0.32-1ubuntu22.04_amd64.deb + sudo dpkg -i mysql-connector-odbc_8.0.32-1ubuntu22.04_amd64.deb + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Set up dependencies + run: pip install -r requirements.txt + + - name: Test + run: PYTHONPATH=src python -m pytest + diff --git a/.github/workflows/scala-build.yml b/.github/workflows/scala-build.yml new file mode 100644 index 00000000..1e90a368 --- /dev/null +++ b/.github/workflows/scala-build.yml @@ -0,0 +1,40 @@ +name: scala-build + +on: + push: + paths: + - 'scala/**' + - '.github/workflows/scala-build.yml' + pull_request: + paths: + - 'scala/**' + - '.github/workflows/scala-build.yml' + +jobs: + build: + runs-on: ubuntu-latest + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Set up Java + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'sbt' + + - name: Build and test + working-directory: scala + run: sbt test diff --git a/.github/workflows/typescript-build.yml b/.github/workflows/typescript-build.yml new file mode 100644 index 00000000..7a2d6d94 --- /dev/null +++ b/.github/workflows/typescript-build.yml @@ -0,0 +1,51 @@ +name: typescript-buld + +env: + PROJECT_DIR: typescript + +on: + push: + paths: + - 'typescript/**' + - '.github/workflows/typescript-build.yml' + pull_request: + paths: + - 'typescript/**' + - '.github/workflows/typescript-build.yml' + +jobs: + build: + defaults: + run: + working-directory: ./${{ env.PROJECT_DIR }} + + runs-on: ubuntu-latest + + env: + DB_USER: root + DB_OLD_PASSWORD: root + DB_PASSWORD: mysql + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Start MYSQL and import DB + run: | + sudo systemctl start mysql + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} version + mysqladmin --user=${{ env.DB_USER }} --password=${{ env.DB_OLD_PASSWORD }} password ${{ env.DB_PASSWORD }} + mysql -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }} < ${GITHUB_WORKSPACE}/database/initDatabase.sql + + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 15.x + + - name: Set up dependencies + run: npm install + + - name: Build and test + run: | + npm run compile + npm test From b7d80b9139936b268161d800a7601a9476779c5f Mon Sep 17 00:00:00 2001 From: Peter Kofler Date: Sat, 8 Jun 2024 21:00:29 +0200 Subject: [PATCH 3/3] Ignore tests in builds on master as these fail. --- .github/workflows/csharp-build.yml | 3 --- .github/workflows/java-build.yml | 2 +- .github/workflows/javascript-build.yml | 4 ---- .github/workflows/python-build.yml | 3 --- .github/workflows/typescript-build.yml | 1 - 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/csharp-build.yml b/.github/workflows/csharp-build.yml index ca73b77e..730e70ba 100644 --- a/.github/workflows/csharp-build.yml +++ b/.github/workflows/csharp-build.yml @@ -61,9 +61,6 @@ jobs: - name: build solution run: dotnet build - - name: run unit tests - run: dotnet test --logger "trx;logfilename=${GITHUB_WORKSPACE}/unit_test_results.xml" - - name: Test Reporter uses: dorny/test-reporter@v1.5.0 if: always() diff --git a/.github/workflows/java-build.yml b/.github/workflows/java-build.yml index 0b6fc939..151651d7 100644 --- a/.github/workflows/java-build.yml +++ b/.github/workflows/java-build.yml @@ -57,7 +57,7 @@ jobs: - name: Build and test run: | - mvn -B clean install + mvn -B clean install -DskipTests - name: Publish Unit Tests uses: EnricoMi/publish-unit-test-result-action@v1.17 diff --git a/.github/workflows/javascript-build.yml b/.github/workflows/javascript-build.yml index 7261484c..46f0df57 100644 --- a/.github/workflows/javascript-build.yml +++ b/.github/workflows/javascript-build.yml @@ -43,7 +43,3 @@ jobs: - name: Set up dependencies run: npm install - - - name: Test - run: npm test - diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index f98edc6c..318bce7d 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -52,6 +52,3 @@ jobs: - name: Set up dependencies run: pip install -r requirements.txt - - name: Test - run: PYTHONPATH=src python -m pytest - diff --git a/.github/workflows/typescript-build.yml b/.github/workflows/typescript-build.yml index 7a2d6d94..5eec3f58 100644 --- a/.github/workflows/typescript-build.yml +++ b/.github/workflows/typescript-build.yml @@ -48,4 +48,3 @@ jobs: - name: Build and test run: | npm run compile - npm test