Skip to content

Commit

Permalink
fix: update workflow
Browse files Browse the repository at this point in the history
Should have been committed in v2.0.0 release
  • Loading branch information
Robert Duncan committed Oct 21, 2023
1 parent 850cc7b commit d35e7ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ jobs:
pip install rich
pip install json_source_map
wget https://raw.githubusercontent.com/robproject/fsjd/main/frappe_schema_json_diff.py
export TABLE_MODE=1
export GIT_EXTERNAL_DIFF=./frappe_schema_json_diff.py
git --no-pager diff
- name: Run script file
run: |
chmod +x ./run.sh
./run.sh
shell: bash
25 changes: 4 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,14 @@

## Usage
### Local Testing

Call the script and pass three arguments:
1. Path to text file containing git statuses and paths to (copied) files from head commit.
2. Path to text file containing git statuses and paths to files from base commit.
3. Boolean for printing tables (1) or trees (0).

Sample Frappe JSON files and a VSCode launch configuration are included to quickly get started (on WSL):
`git clone --recurse-submodules https://github.com/robproject/fsjd.git`
`cd fsjd && pip install -r requirements.txt && code .`
Press f5
1. Change or delete any json files located in /test_files
2. `bash ./run.sh`

### CI Implementation
Copy the file `.github/workflows/main.yaml` along with its parent directories into the root folder of a custom app. Change the branch on lines 4 and 6 if applicable. Keep the `1` on line 71 to print table diffs or change it to `0` for trees.

Copy the file `.github/workflows/main.yaml` along with its parent directories into the root folder of a custom app. Change the branch on lines 4 and 6 if applicable. Keep the `1` on line 23 to print table diffs or change it to `0` for trees.

## Output
Runner terminals will show all JSON file names and git statuses, and any diff contents for those which are renamed or modified. If any schema changes (changed JSON) are present, the workflow will fail.
Runner terminals will show JSON file names and diff content for any modified files, and names of deleted files. If any schema changes (changed JSON) are present, the workflow will fail.
### CI Terminal
[example](https://github.com/robproject/fsjd/runs/8027932932?check_suite_focus=true#step:8:5)
### Table
Expand All @@ -31,13 +22,5 @@ Runner terminals will show all JSON file names and git statuses, and any diff co
| ------------------- | ------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| **json-source-map** | Fetching line numbers for diffed data | [PyPI](https://pypi.org/project/json-source-map/) [GitHub](https://github.com/open-alchemy/json-source-map/wiki) |
| **Rich** | Python output formatting | [PyPI](https://pypi.org/project/rich/) [GitHub](https://github.com/Textualize/rich) |
### Github Actions
Workflow `main.yaml` performs the following steps:
1. Checkout action gets the two latest commits.
2. Changed-files action gets all changed json.
3. Changed files are copied to a directory `head/` while their new paths and git status are listed in a file `acmr.txt`.
4. Git checks out the base commit.
5. Git status and changed file paths of base files are listed in file `base/mrd.txt`.
6. Script can be called since both versions of files are accessible.
### Function
A specific situation this tool is designed to account for is the deletion or reordering of elements in a list of dictionaries. If docfields (dictionaries) are added, deleted, or have their order changed, tools like DeepDiff will compare elements of the same index. FSJD will compare members of dictionary lists with matching common-key values. For example, docfields share the common-key 'field_name', so if two lists to be diffed contain dictionaries with this common-key, and their values match, those two dictionaries will be compared regardless of index. The tradeoff to this approach is that renaming a docfield (changing only the value of a common-key) will show a deleted and added docfield instead of a renamed value.

0 comments on commit d35e7ea

Please sign in to comment.