From bc17df945592b40a898d35a91244f636b0de0634 Mon Sep 17 00:00:00 2001 From: Tristan Menzel Date: Fri, 6 Dec 2024 08:10:00 -0800 Subject: [PATCH] build: Tweak approval tests for ci --- .github/workflows/ci-all.yml | 2 ++ .github/workflows/node-ci.yml | 2 +- package-lock.json | 20 +++++++++++++++++++ package.json | 3 ++- tests/approvals.spec.ts | 11 ++++++---- ...11Contract.ssa.ir => AVM11Contract.ssa.ir} | 0 .../{Avm11Sig.ssa.ir => AVM11SIG.ssa.ir} | 0 tests/constants.ts | 3 +++ 8 files changed, 35 insertions(+), 6 deletions(-) rename tests/approvals/out/avm11/{Avm11Contract.ssa.ir => AVM11Contract.ssa.ir} (100%) rename tests/approvals/out/avm11/{Avm11Sig.ssa.ir => AVM11SIG.ssa.ir} (100%) create mode 100644 tests/constants.ts diff --git a/.github/workflows/ci-all.yml b/.github/workflows/ci-all.yml index c9458b6f..9be04e46 100644 --- a/.github/workflows/ci-all.yml +++ b/.github/workflows/ci-all.yml @@ -49,3 +49,5 @@ jobs: pipx install algokit --python 3.12.6 algokit localnet reset --update pipx install git+https://github.com/algorandfoundation/puya --python 3.12.6 + test-script: npm run test:ci + output-test-results: true diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index f569f3d8..9ed07ff4 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -162,7 +162,7 @@ jobs: #Requires permissions.checks: write - name: Publish test results - if: ${{ inputs.output-test-results }} + if: ${{ inputs.output-test-results && always() }} uses: phoenix-actions/test-reporting@v10 with: name: Test results diff --git a/package-lock.json b/package-lock.json index 218577eb..1679b107 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,6 +44,7 @@ "better-npm-audit": "3.11.0", "conventional-changelog-conventionalcommits": "^8.0.0", "copyfiles": "2.4.1", + "cross-env": "^7.0.3", "eslint": "9.15.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", @@ -3834,6 +3835,25 @@ "typescript": ">=4" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", diff --git a/package.json b/package.json index 3ff0a0ce..d391d41a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "test:approvals": "vitest run tests/approvals.spec.ts", "test:expected-output": "vitest run tests/expected-output.spec.ts", "test:coverage": "vitest run --coverage", - "test:ci": "vitest run --coverage --reporter junit --outputFile test-results.xml", + "test:ci": "cross-env NODE_ENV=ci vitest run --coverage", "install-local-packages": "npm run algo-ts", "watch-local-packages": "npm run algo-ts:build:watch", "algo-ts": "run-s algo-ts:*", @@ -60,6 +60,7 @@ "better-npm-audit": "3.11.0", "conventional-changelog-conventionalcommits": "^8.0.0", "copyfiles": "2.4.1", + "cross-env": "^7.0.3", "eslint": "9.15.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-prettier": "^5.2.1", diff --git a/tests/approvals.spec.ts b/tests/approvals.spec.ts index 770f88d4..042d2d47 100644 --- a/tests/approvals.spec.ts +++ b/tests/approvals.spec.ts @@ -6,6 +6,7 @@ import { buildCompileOptions } from '../src/compile-options' import { isErrorOrCritical, LoggingContext, LogLevel } from '../src/logger' import { defaultPuyaOptions } from '../src/puya/options' import { invariant } from '../src/util' +import { Environment } from './constants' describe('Approvals', async () => { await rimraf('tests/approvals/out') @@ -55,10 +56,12 @@ describe('Approvals', async () => { }) it('There should be no differences to committed changes', () => { - // // Run git add to force line ending changes - // sync('git', ['add', '.'], { - // stdio: 'inherit', - // }) + if (Environment.IsCi) { + // Run git add to force line ending changes + sync('git', ['add', '.'], { + stdio: 'inherit', + }) + } const result = sync('git', ['status', '--porcelain'], { stdio: 'pipe', }) diff --git a/tests/approvals/out/avm11/Avm11Contract.ssa.ir b/tests/approvals/out/avm11/AVM11Contract.ssa.ir similarity index 100% rename from tests/approvals/out/avm11/Avm11Contract.ssa.ir rename to tests/approvals/out/avm11/AVM11Contract.ssa.ir diff --git a/tests/approvals/out/avm11/Avm11Sig.ssa.ir b/tests/approvals/out/avm11/AVM11SIG.ssa.ir similarity index 100% rename from tests/approvals/out/avm11/Avm11Sig.ssa.ir rename to tests/approvals/out/avm11/AVM11SIG.ssa.ir diff --git a/tests/constants.ts b/tests/constants.ts new file mode 100644 index 00000000..13ee3391 --- /dev/null +++ b/tests/constants.ts @@ -0,0 +1,3 @@ +export const Environment = { + IsCi: process.env.NODE_ENV === 'ci', +} as const