Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test usage and clarity #34

Merged
merged 4 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 18 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,36 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Targets specific directory
- name: Test on affected directory
uses: ./
with:
directory: "tests/action/directory/a/*"
directory: "tests/directory/affected/*"

- name: Compare the minified files
run: git diff --exit-code
- name: Assert not affected result does not exist
run: |
! test -e tests/directory/not-affected/main.min.js

- name: Assert affected result matches expected
run: |
git diff --exit-code --no-index \
tests/directory/affected/main.expected.js \
tests/directory/affected/main.min.js

overwrite:
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4

- name: Test successful overwrite
uses: ./
with:
directory: "tests/action/overwrite/overwritten/*"
overwrite: true

- name: Assert successful overwrite
run: |
git diff --exit-code tests/action/overwrite/overwritten/*

- name: Test failed overwrite

- name: Test overwrite
uses: ./
with:
directory: "tests/action/overwrite/not-overwritten/*"
directory: "tests/overwrite/*"
overwrite: true

- name: Assert failed overwrite
- name: Assert overwrite result matches expected
run: |
! git diff --exit-code tests/action/overwrite/not-overwritten/*
git diff --exit-code --no-index \
tests/overwrite/main.expected.js \
tests/overwrite/main.js
1 change: 0 additions & 1 deletion tests/action/directory/a/a.min.js

This file was deleted.

1 change: 0 additions & 1 deletion tests/action/overwrite/overwritten/main.js

This file was deleted.

1 change: 1 addition & 0 deletions tests/directory/affected/main.expected.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from overwrite/not-overwritten');
console.log('hello world from directory/affected');
}

window.addEventListener('load', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from b');
console.log('hello world from directory/ignored');
nizarmah marked this conversation as resolved.
Show resolved Hide resolved
}

window.addEventListener('load', function () {
Expand Down
1 change: 1 addition & 0 deletions tests/overwrite/main.expected.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/action/directory/a/a.js → tests/overwrite/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function print_hello() {
console.log('hello world from a');
console.log('hello world from overwrite');
}

window.addEventListener('load', function () {
Expand Down