Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .github/workflows/update visual snapshots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,23 @@ jobs:
npm install
luarocks install --lua-version=5.1 busted

# Very slow (3mins) - can probably be made faster using http://github.com/microsoft/playwright/issues/23388
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Compile stylesheets
run: npm run build:css

- name: Generate HTML from Lua
id: generate-lua
env:
UPDATE_SNAPSHOTS: true
GITHUB_CI: true
run: |
echo 'GENERATED_ARGS<<EOF' >> "$GITHUB_ENV"
busted -C lua
echo EOF >> "$GITHUB_ENV"

- name: Update snapshots
run: UPDATE_SNAPSHOTS=true npm run lua-test
uses: docker://mcr.microsoft.com/playwright:v1.55.0-noble
with:
args: ${{ steps.generate-lua.outputs.GENERATED_ARGS }}

- name: Commit and push if snapshots changed
uses: stefanzweifel/git-auto-commit-action@v6
Expand Down
11 changes: 11 additions & 0 deletions lua/spec/helpers/test_helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ return function(busted, helper, options)
file:close()
end

local function appendFile(fileName, data)
local file = assert(io.open(fileName, 'a+'))
file:write(data)
file:close()
end

local function GoldenTest(testName, actual)
-- Currently we're only running snapshots tests while updating them too
if os.getenv('UPDATE_SNAPSHOTS') ~= 'true' then
Expand All @@ -129,6 +135,11 @@ return function(busted, helper, options)
nodeJsCommand = nodeJsCommand .. ' --update-snapshots'
end

if os.getenv('GITHUB_CI') == 'true' then
appendFile(os.getenv('GITHUB_ENV'), nodeJsCommand .. '\n')
return
end

local exitCode = os.execute(nodeJsCommand)
os.remove(finalHtmlPath)

Expand Down
Loading