Skip to content

Commit

Permalink
Release v1 - Merge #6
Browse files Browse the repository at this point in the history
  • Loading branch information
hudsonm62 authored Apr 27, 2024
2 parents c9bb93b + 9f9e0b8 commit 1230a46
Show file tree
Hide file tree
Showing 13 changed files with 335 additions and 174 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# syntax=docker/dockerfile:1

# provided for convenience
FROM oven/bun:alpine

# Config Bun
ENV PATH="~/.bun/bin:${PATH}"
RUN ln -s /usr/local/bin/bun /usr/local/bin/node

# Update packages
RUN apk update && \
apk add --no-cache git \
&& rm -rf /var/cache/apk/*

RUN bun -v
11 changes: 11 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "Bun Alpine Environment",
"dockerFile": "dev.Dockerfile",
"waitFor": "postStartCommand",
"postStartCommand": "bun install",
"customizations": {
"vscode": {
"extensions": ["oven.bun-vscode"]
}
}
}
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* text=lf
*.lockb binary diff=lockb
100 changes: 2 additions & 98 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,102 +28,6 @@ jobs:
- name: 📦 Build Package
run: bun run bundle -o dist-ci --debug

- name: Verify output with commited
- name: ✅ Verify output with Commited
#uses: hudsonm62/compare-action@v1
run: diff -qr dist dist-ci

# todo - could probably add more steps still
test-action:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Test Action (local)
steps:
- name: ⚙️ Checkout Repo
uses: actions/checkout@v4
- name: Normal Folder Compare
uses: ./
with:
path1: "./__tests__/compare/directory1"
path2: "./__tests__/compare/directory2"
output_diff: true

- name: Normal File Compare
uses: ./
with:
path1: "./__tests__/compare/m_file1.txt"
path2: "./__tests__/compare/m_file3.txt"
output_diff: true

- name: Normal File Compare
uses: ./
with:
path1: "./__tests__/compare/m_file1.txt"
path2: "./__tests__/compare/m_file3.txt"
output_diff: true

- name: Exclude File Compare
uses: ./
with:
path1: "./__tests__/compare/directory1"
path2: "./__tests__/compare/directory2"
exclude: "d_file2.txt"
output_diff: true

# checks root compare vs directory1 (which contain identical files except the folders), so ignore the folders and compare roots
- name: Exclude Folders and Files
uses: ./
with:
path1: "./__tests__/compare"
path2: "./__tests__/compare/directory1"
exclude: "d_file2.txt,directory2,directory1"
output_diff: true

- name: Test no error
uses: ./
with:
path1: "./__tests__/compare/d_file2.txt"
path2: "./__tests__/compare/m_file1.txt"
no_error: true
output_diff: true

- name: Test warn instead
uses: ./
with:
path1: "./__tests__/compare/d_file2.txt"
path2: "./__tests__/compare/m_file1.txt"
warn_instead: true
output_diff: true

- name: Test error same (same files)
continue-on-error: true
uses: ./
with:
path1: "./__tests__/compare/m_file1.txt"
path2: "./__tests__/compare/m_file1.txt"
error_same: true
output_diff: true
- name: Test error same (different files)
continue-on-error: false # shouldn't fail, since its erroring on matches
uses: ./
with:
path1: "./__tests__/compare/m_file1.txt"
path2: "./__tests__/compare/d_file2.txt"
error_same: true
output_diff: true

- name: Test Exclude Glob1
uses: ./
with:
path1: "./__tests__/compare"
path2: "./__tests__/compare"
exclude: "**/d_file2.txt"
output_diff: true
- name: Test Exclude Glob2
uses: ./
with:
path1: "./__tests__/compare"
path2: "./__tests__/compare"
exclude: "**/*.txt"
no_error: true
output_diff: true
201 changes: 201 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
name: Test Action

on: push

env:
TEST_DIR: ./__tests__/compare

permissions:
contents: read
jobs:
# todo - could probably add more steps still
test-action:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Test Action
steps:
- name: ⚙️ Checkout Repo
uses: actions/checkout@v4
- name: Normal Folder Compare
uses: ./
with:
path1: "${{ env.TEST_DIR }}/directory1"
path2: "${{ env.TEST_DIR }}/directory2"
output_diff: true

- name: Normal File Compare
uses: ./
with:
path1: "${{ env.TEST_DIR }}/m_file1.txt"
path2: "${{ env.TEST_DIR }}/m_file3.txt"
output_diff: true

- name: Exclude File Compare
uses: ./
with:
path1: "${{ env.TEST_DIR }}/directory1"
path2: "${{ env.TEST_DIR }}/directory2"
exclude: "d_file2.txt"
output_diff: true

# checks root compare vs directory1 (which contain identical files except the folders), so ignore the folders and compare roots
- name: Exclude Folders and Files
uses: ./
with:
path1: "${{ env.TEST_DIR }}"
path2: "${{ env.TEST_DIR }}/directory1"
exclude: "d_file2.txt,directory2,directory1"
output_diff: true

- name: Test no error
uses: ./
with:
path1: "${{ env.TEST_DIR }}/d_file2.txt"
path2: "${{ env.TEST_DIR }}/m_file1.txt"
no_error: true
output_diff: true

- name: Test warn instead
uses: ./
with:
path1: "${{ env.TEST_DIR }}/d_file2.txt"
path2: "${{ env.TEST_DIR }}/m_file1.txt"
warn_instead: true
output_diff: true

- name: Test error same (same files)
continue-on-error: true
uses: ./
with:
path1: "${{ env.TEST_DIR }}/m_file1.txt"
path2: "${{ env.TEST_DIR }}/m_file1.txt"
error_same: true
output_diff: true

- name: Test error same (different files)
continue-on-error: false # shouldn't fail, since its erroring on matches
uses: ./
with:
path1: "${{ env.TEST_DIR }}/m_file1.txt"
path2: "${{ env.TEST_DIR }}/d_file2.txt"
error_same: true
output_diff: true

- name: Test Exclude Glob1 (file name)
uses: ./
with:
path1: "${{ env.TEST_DIR }}"
path2: "${{ env.TEST_DIR }}"
exclude: "**/d_file2.txt"
output_diff: true

- name: Test Exclude Glob2 (file ext)
uses: ./
with:
path1: "${{ env.TEST_DIR }}"
path2: "${{ env.TEST_DIR }}"
exclude: "**/*.txt"
output_diff: true

- name: Test Exclude Glob3 (folder name)
uses: ./
with:
path1: "${{ env.TEST_DIR }}"
path2: "${{ env.TEST_DIR }}"
exclude: "**/directory1/**"
output_diff: true

- name: No diff output
uses: ./
with:
path1: "${{ env.TEST_DIR }}/"
path2: "${{ env.TEST_DIR }}/"
output_diff: false

# this works, because directory1/2 are ignored in `path2` (the file content is the same)
### Ignore that, this doesn't work - see https://github.com/gliviu/dir-compare/issues/77
- name: Ignore Subdirectories
if: false
uses: ./
with:
path1: "${{ env.TEST_DIR }}/directory1"
path2: "${{ env.TEST_DIR }}"
output_diff: true
ignore_subdirs: true

test-logging:
needs: test-action
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
name: Test Action Logging
permissions:
contents: write
steps:
- name: ⚙️ Checkout Repo
uses: actions/checkout@v4

- id: short-sha
uses: hudsonm62/short-sha@v1

- name: Normal Folder Compare
uses: ./
id: folder_compare
with:
path1: "${{ env.TEST_DIR }}/directory1"
path2: "${{ env.TEST_DIR }}/directory2"
output_diff: true
log_path: "./some_log1.log" # on the cwd
- name: Normal File Compare
uses: ./
id: file_compare
with:
path1: "${{ env.TEST_DIR }}/m_file1.txt"
path2: "${{ env.TEST_DIR }}/m_file3.txt"
output_diff: true
log_path: "./some_log2.log" # on the cwd

- name: compare logs (arent matching) # because why not
uses: ./
with:
path1: "./some_log1.log"
path2: "./some_log2.log"
output_diff: true
error_same: true

- name: Upload Log 1
uses: actions/upload-artifact@v4
with:
name: "log1-${{ steps.short-sha.outputs.sha }}-${{ matrix.os }}"
path: "${{ steps.folder_compare.outputs.log_path }}"
compression-level: 9

- name: Upload Log 2
uses: actions/upload-artifact@v4
with:
name: "log2-${{ steps.short-sha.outputs.sha }}-${{ matrix.os }}"
path: "${{ steps.file_compare.outputs.log_path }}"
compression-level: 9

- name: Folder output step outputs
run: |
echo "Result: ${{ steps.folder_compare.outputs.result }}"
echo "Log Path: ${{ steps.folder_compare.outputs.log_path }}"
echo "Equal: ${{ steps.folder_compare.outputs.equal }}"
echo "Different: ${{ steps.folder_compare.outputs.different }}"
echo "Total Folders: ${{ steps.folder_compare.outputs.total_folders }}"
echo "Total Files: ${{ steps.folder_compare.outputs.total_files }}"
echo "Total: ${{ steps.folder_compare.outputs.total }}"
- name: File output step outputs
run: |
echo "Result: ${{ steps.file_compare.outputs.result }}"
echo "Log Path: ${{ steps.file_compare.outputs.log_path }}"
echo "Equal: ${{ steps.file_compare.outputs.equal }}"
echo "Different: ${{ steps.file_compare.outputs.different }}"
echo "Total Folders: ${{ steps.file_compare.outputs.total_folders }}"
echo "Total Files: ${{ steps.file_compare.outputs.total_files }}"
echo "Total: ${{ steps.file_compare.outputs.total }}"
Loading

0 comments on commit 1230a46

Please sign in to comment.