diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 6c857f6..0e6d56d 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -29,5 +29,10 @@ jobs: run: npm run build - name: Upload results to Codecov uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + token: ${{ secrets.CODECOV_TOKEN }} + - name: Upload junit test results to Codecov + if: ${{ !cancelled() }} + uses: codecov/test-results-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/check-version-bump.yml b/.github/workflows/check-version-bump.yml new file mode 100644 index 0000000..84163e3 --- /dev/null +++ b/.github/workflows/check-version-bump.yml @@ -0,0 +1,22 @@ +--- +name: Check Version Bump + +on: + pull_request: + +jobs: + check-version-bump: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check if version has been updated + id: check + uses: EndBug/version-check@v2 + + - name: Log when changed + if: steps.check.outputs.changed == 'true' + run: 'echo "Version change found in commit ${{ steps.check.outputs.commit }}! New version: ${{ steps.check.outputs.version }} (${{ steps.check.outputs.type }})"' + + - name: Log when unchanged + if: steps.check.outputs.changed == 'false' + run: 'echo "No version change! Please bump the version in package.json!" && exit 1' diff --git a/.gitignore b/.gitignore index 831fa76..2e99f1c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ npm-debug.log !mock-cert.pem .env* coverage +junit.xml bin temp/* diff --git a/jest.config.js b/jest.config.js index 44ead85..f016be9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,6 +1,7 @@ module.exports = { testEnvironment: 'node', roots: ['/test'], + reporters: ['default', 'jest-junit'], testMatch: ['**/*.test.ts'], transform: { '^.+\\.tsx?$': 'ts-jest', diff --git a/package-lock.json b/package-lock.json index b3b9c7a..1876134 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "opensearch-automation-app", - "version": "0.1.0", + "version": "0.1.2", "lockfileVersion": 3, "requires": true, "packages": { @@ -40,6 +40,7 @@ "eslint-plugin-import": "^2.30.0", "globals": "^15.9.0", "jest": "^29.7.0", + "jest-junit": "^16.0.0", "nock": "^14.0.0-beta.5", "prettier": "^3.3.3", "smee-client": "^2.0.0", @@ -9159,6 +9160,42 @@ "fsevents": "^2.3.2" } }, + "node_modules/jest-junit": { + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-16.0.0.tgz", + "integrity": "sha512-A94mmw6NfJab4Fg/BlvVOUXzXgF0XIH6EmTgJ5NDPp4xoKq0Kr7sErb+4Xs9nZvu58pJojz5RFGpqnZYJTrRfQ==", + "dev": true, + "dependencies": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^8.3.2", + "xml": "^1.0.1" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/jest-junit/node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-junit/node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "dev": true, + "bin": { + "uuid": "dist/bin/uuid" + } + }, "node_modules/jest-leak-detector": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.7.0.tgz", @@ -12893,6 +12930,12 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index 8206e70..8888cd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opensearch-automation-app", - "version": "0.1.0", + "version": "0.1.2", "description": "An Automation App that handles all your GitHub Repository Activities", "author": "Peter Zhu", "homepage": "https://github.com/opensearch-project/automation-app", @@ -22,7 +22,7 @@ "format": "prettier --write src/**/*.ts test/**/*.ts configs/**/*.yml", "format-dryrun": "prettier --check src/**/*.ts test/**/*.ts configs/**/*.yml", "lint": "eslint --fix \"src/**/*.ts\" --ignore-pattern \"**/*.d.ts\"", - "test": "jest --coverage" + "test": "jest --coverage --reporters=jest-junit" }, "dependencies": { "@aws-sdk/client-opensearch": "^3.658.1", @@ -54,6 +54,7 @@ "eslint-plugin-import": "^2.30.0", "globals": "^15.9.0", "jest": "^29.7.0", + "jest-junit": "^16.0.0", "nock": "^14.0.0-beta.5", "prettier": "^3.3.3", "smee-client": "^2.0.0", diff --git a/src/call/github-merged-pulls-monitor.ts b/src/call/github-merged-pulls-monitor.ts index 342a0ec..e9495a2 100644 --- a/src/call/github-merged-pulls-monitor.ts +++ b/src/call/github-merged-pulls-monitor.ts @@ -72,7 +72,7 @@ export default async function githubMergedPullsMonitor(app: Probot, context: any const [month, year] = [new Date().getMonth() + 1, new Date().getFullYear()].map((num) => String(num).padStart(2, '0')); try { - await new OpensearchClient().bulkIndex(`github-pulls-ci-runs-checks-${month}-${year}`, logDataArray); + await new OpensearchClient().bulkIndex(`github-pulls-ci-workflow-runs-${month}-${year}`, logDataArray); app.log.info('All log data indexed successfully.'); } catch (error) { app.log.error(`Error indexing log data: ${error}`); diff --git a/test/call/github-merged-pulls-monitor.test.ts b/test/call/github-merged-pulls-monitor.test.ts index 42a3b3a..6260c0e 100644 --- a/test/call/github-merged-pulls-monitor.test.ts +++ b/test/call/github-merged-pulls-monitor.test.ts @@ -97,7 +97,7 @@ describe('githubMergedPullsMonitor', () => { ref: 'abcdef123456', }); expect(mockBulkIndex).toHaveBeenCalledWith( - expect.stringMatching(/^github-pulls-ci-runs-checks-\d{2}-\d{4}$/), + expect.stringMatching(/^github-pulls-ci-workflow-runs-\d{2}-\d{4}$/), expect.arrayContaining([ expect.objectContaining({ number: 123,