diff --git a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/action.yml b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/action.yml index 28a6786160b..160f7287dfc 100644 --- a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/action.yml +++ b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/action.yml @@ -4,8 +4,11 @@ inputs: repo-token: description: 'GitHub token' required: true - compare: - description: 'Path checkstyle.xml file' + checkstyle: + description: 'Path checkstyle.xml file of current PR/branch' + required: true + checkstyle-trunk: + description: 'Path checkstyle.xml file of trunk' required: true runs: diff --git a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/index.js b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/index.js index 03d5610c762..cde3469857e 100644 --- a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/index.js +++ b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/index.js @@ -4,7 +4,7 @@ const { setFailed, getInput } = require( '@actions/core' ); const { parseXml, getFilesWithNewErrors } = require( './utils/xml' ); const { generateMarkdownMessage } = require( './utils/markdown' ); const { addRecord } = require( './utils/airtable' ); -const { getFileContent, addComment } = require( './utils/github' ); +const { addComment } = require( './utils/github' ); const runner = async () => { const token = getInput( 'repo-token', { required: true } ); @@ -12,27 +12,18 @@ const runner = async () => { const payload = context.payload; const repo = payload.repository.name; const owner = payload.repository.owner.login; - const fileName = getInput( 'compare', { + const fileName = getInput( 'checkstyle', { + required: true, + } ); + const trunkFileName = getInput( 'checkstyle-trunk', { required: true, } ); const newCheckStyleFile = fs.readFileSync( fileName ); const newCheckStyleFileParsed = parseXml( newCheckStyleFile ); - const currentCheckStyleFile = await getFileContent( { - octokit, - owner, - repo, - fileName, - onFail: setFailed, - } ); - - if ( ! currentCheckStyleFile.data ) { - setFailed( 'No Content Available' ); - return; - } - + const currentCheckStyleFile = fs.readFileSync( trunkFileName ); const currentCheckStyleFileContentParsed = parseXml( - currentCheckStyleFile.data + currentCheckStyleFile ); const { header } = generateMarkdownMessage( newCheckStyleFileParsed ); diff --git a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/utils/github.js b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/utils/github.js index 381b81d5577..2b49d0f3aae 100644 --- a/plugins/woocommerce-blocks/.github/monitor-typescript-errors/utils/github.js +++ b/plugins/woocommerce-blocks/.github/monitor-typescript-errors/utils/github.js @@ -1,28 +1,3 @@ -exports.getFileContent = async ( { - octokit, - owner, - repo, - fileName, - onFail, -} ) => { - try { - return await octokit.rest.repos.getContent( { - owner, - repo, - path: fileName, - mediaType: { - format: 'raw', - }, - } ); - } catch ( err ) { - if ( err.status === '404' ) { - return; - } - - onFail( err.message ); - } -}; - const getReportCommentId = async ( { octokit, owner, repo, payload } ) => { const currentComments = await octokit.rest.issues.listComments( { owner, diff --git a/plugins/woocommerce-blocks/.github/workflows/typescript-monitoring.yml b/plugins/woocommerce-blocks/.github/workflows/typescript-monitoring.yml index 7c36bbf9925..6afbf1cf2a8 100644 --- a/plugins/woocommerce-blocks/.github/workflows/typescript-monitoring.yml +++ b/plugins/woocommerce-blocks/.github/workflows/typescript-monitoring.yml @@ -8,9 +8,9 @@ jobs: check-typescript-errors-with-trunk: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: - ref: ${{ github.event.pull_request.head.ref }} + ref: 'trunk' - name: Cache node modules uses: actions/cache@v3 @@ -30,10 +30,19 @@ jobs: node-version-file: '.nvmrc' cache: 'npm' - - name: npm install + - name: Generate checkstyle for trunk run: | npm ci npm run ts:log-errors + mv checkstyle.xml $HOME/checkstyle-trunk.xml + + - uses: actions/checkout@v3 + + - name: Generate checkstyle for current PR + run: | + npm ci + npm run ts:log-errors + mv $HOME/checkstyle-trunk.xml checkstyle-trunk.xml - name: Get branch name id: branch-name @@ -43,21 +52,8 @@ jobs: uses: ./.github/monitor-typescript-errors with: repo-token: '${{ secrets.GITHUB_TOKEN }}' - compare: checkstyle.xml + checkstyle: checkstyle.xml + checkstyle-trunk: checkstyle-trunk.xml env: AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} CURRENT_BRANCH: ${{ steps.branch-name.outputs.current_branch }} - - - name: Check if the checklist.xml file is changed - id: verify_diff - run: | - git diff --quiet checkstyle.xml || echo "is_different_checkstyle=true" >> $GITHUB_OUTPUT - - - name: Commit the new checklist.xml file - if: steps.verify_diff.outputs.is_different_checkstyle == 'true' - run: | - git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - git add checkstyle.xml - git commit -m "bot: update checkstyle.xml" - git push diff --git a/plugins/woocommerce-blocks/checkstyle.xml b/plugins/woocommerce-blocks/checkstyle.xml deleted file mode 100644 index cf45d060794..00000000000 --- a/plugins/woocommerce-blocks/checkstyle.xml +++ /dev/null @@ -1,4185 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -