From 9269e98a4a140b1843359445e81cd8cf84c26a82 Mon Sep 17 00:00:00 2001 From: salman Date: Mon, 4 Nov 2024 11:54:42 +0300 Subject: [PATCH 1/3] created a workflow --- .github/workflows/stryker.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/stryker.yml diff --git a/.github/workflows/stryker.yml b/.github/workflows/stryker.yml new file mode 100644 index 0000000000..c330e55e80 --- /dev/null +++ b/.github/workflows/stryker.yml @@ -0,0 +1,39 @@ +name: Stryker Mutation Testing + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + mutation-testing: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' # Ensure this matches the Node version your project uses + + - name: Install dependencies + run: npm install + + - name: Run tests + run: npm test # Ensure your tests are working before running Stryker + + - name: Install Stryker + run: npm install --save-dev @stryker-mutator/core + + - name: Run Stryker Mutation Testing + run: npx stryker run + + - name: Upload Stryker Report + if: success() || failure() + uses: actions/upload-artifact@v2 + with: + name: stryker-report + path: reports/mutation/html From d8b60c2396b303b43dd5ad25bbb0826dc62bfc85 Mon Sep 17 00:00:00 2001 From: salman Date: Mon, 4 Nov 2024 12:16:40 +0300 Subject: [PATCH 2/3] changed the stryker file --- .github/workflows/stryker.yml | 66 +++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/.github/workflows/stryker.yml b/.github/workflows/stryker.yml index c330e55e80..9d168546b0 100644 --- a/.github/workflows/stryker.yml +++ b/.github/workflows/stryker.yml @@ -1,36 +1,90 @@ +# Done with help of AI name: Stryker Mutation Testing on: push: - branches: [main] + branches: [f24] pull_request: - branches: [main] + branches: [f24] + +permissions: + contents: read # for actions/checkout to fetch code jobs: mutation-testing: runs-on: ubuntu-latest + env: + TEST_ENV: 'production' + + services: + redis: + image: 'redis:7.2.4' + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 6379:6379 steps: + # Step 1: Check out repository code - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + # Step 2: Copy package.json (adjust if needed) + - run: cp install/package.json package.json + + # Step 3: Set up Node.js - name: Set up Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: '16' # Ensure this matches the Node version your project uses + node-version: '20' + # Step 4: Install dependencies - name: Install dependencies run: npm install + # Step 5: Setup Redis environment + - name: Setup for Redis + env: + SETUP: >- + { + "url": "http://127.0.0.1:4567/forum", + "secret": "abcdef", + "admin:username": "admin", + "admin:email": "test@example.org", + "admin:password": "hAN3Eg8W", + "admin:password:confirm": "hAN3Eg8W", + "database": "redis", + "redis:host": "127.0.0.1", + "redis:port": 6379, + "redis:password": "", + "redis:database": 0 + } + CI: >- + { + "host": "127.0.0.1", + "database": 1, + "port": 6379 + } + run: | + node app --setup="${SETUP}" --ci="${CI}" + + # Step 6: Run tests to ensure they pass before running Stryker - name: Run tests - run: npm test # Ensure your tests are working before running Stryker + run: npm test + # Step 7: Install Stryker - name: Install Stryker run: npm install --save-dev @stryker-mutator/core + # Step 8: Run Stryker Mutation Testing - name: Run Stryker Mutation Testing run: npx stryker run + # Step 9: Upload Stryker HTML Report as an artifact - name: Upload Stryker Report if: success() || failure() uses: actions/upload-artifact@v2 From bb3064414818b95080a1dae2b24ba20d5f315797 Mon Sep 17 00:00:00 2001 From: salman Date: Mon, 4 Nov 2024 14:22:03 +0300 Subject: [PATCH 3/3] added comments --- .github/workflows/stryker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/stryker.yml b/.github/workflows/stryker.yml index 9d168546b0..11b8b131c1 100644 --- a/.github/workflows/stryker.yml +++ b/.github/workflows/stryker.yml @@ -1,4 +1,4 @@ -# Done with help of AI +# Done with help of AI chatgpt name: Stryker Mutation Testing on: