Skip to content

generate one tree per PR#341

Open
bprize15 wants to merge 57 commits into
masterfrom
fix/improve-upload-workflow
Open

generate one tree per PR#341
bprize15 wants to merge 57 commits into
masterfrom
fix/improve-upload-workflow

Conversation

@bprize15

Copy link
Copy Markdown
Collaborator

No description provided.

@bprize15 bprize15 requested a review from ReshmaRamaiah10 May 26, 2026 14:30
run-go-commands:
runs-on: ubuntu-latest
needs: check-changes
if: ${{ always() && needs.check-changes.outputs.has_tsv_changes == 'true' }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need always() here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, will remove.

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need fetch-depth: 0

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tj-actions/changed-files action needs the entire Git history to accurately calculate which files changed.

working-directory: ./web/src/main/go
run: go build -o release-tree ./cmd/release-tree

- name: Get all changed TSV files

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we doing this step again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could probably combine into one big git action or pass the files along, but I think this makes the flow clearer at the cost of a pretty quick git action.

env:
CHANGED_FILES: ${{ steps.changed-tsv-files.outputs.all_changed_files }}
run: |
./release-tree $CHANGED_FILES

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use steps.changed-tsv-files.outputs.all_changed_files directly in the run command instead of env variable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since changed files is a whitespace separated list of files, handling it using an env variable causes the action to treat it as a single argument rather than separate arguments.


- name: Validate mappings
working-directory: ./web/src/main/go
run: ./validate-mappings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use go run instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stackoverflow article explains pretty well: https://stackoverflow.com/questions/61060768/why-is-it-recommended-to-use-go-build-instead-of-go-run-when-running-a-go-ap.

Point 3 is the main use for CI/CD

fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
mostRecentTree := sortedTreeFiles[len(sortedTreeFiles)-2] // most recent will be the one just uploaded

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems misleading. mostRecentTree is the second-to-last tree but seems like it's the new tree that was just uploaded.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. I was trying to explain that I was using -2 because -1 is the one just uploaded. I'll make it clearer.

treeBytes, err := json.Marshal(tree)
if err != nil {
log.Fatalf("Error marshalling tree created from %v: %v\n", file, err)
os.Exit(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is os.Exit(1) redundant since log.Fatalf logs the error and exits the program with status 1.


err = os.WriteFile(filepath.Join(internal.TREE_FILES_PATH, jsonFilename), treeBytes, os.ModePerm)
if err != nil {
fmt.Fprintf(os.Stderr, "Error writing file %v: %v", jsonFilename, err)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use log to log this error to be consistent

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a pattern I like better to have control of exit codes. Just my preference. Can change if you want.

@bprize15 bprize15 requested a review from ReshmaRamaiah10 June 30, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants