5252 # ----------------------------------------
5353 # 'create-comment' step
5454 # ----------------------------------------
55+ - name : Download artifacts
56+ if : ${{ inputs.step == 'create-comment' }}
57+ uses : actions/download-artifact@v4
58+
59+ - name : Move artifacts to home directory
60+ run : |
61+ # Move artifacts to home directory
62+ mkdir $HOME/artifacts
63+ mv ./* $HOME/artifacts
64+ shell : bash
65+
66+ - name : Get variables from artifacts
67+ if : ${{ inputs.step == 'create-comment' }}
68+ id : env-variables-artifacts
69+ run : |
70+ # Get compared hashes
71+ hash_base=$(yq e '.metadata.hash_base' $HOME/artifacts/validator-metadata/validator-metadata.yml)
72+ hash_feature=$(yq e '.metadata.hash_feature' $HOME/artifacts/validator-metadata/validator-metadata.yml)
73+
74+ # Assert variables found
75+ if [[ -z $hash_base || -z $hash_feature ]]; then
76+ echo "Error: Commit hashes not found"
77+ exit 1
78+ fi
79+
80+ # Print and save variables
81+ echo "Main commit hash: ${hash_base}"
82+ echo "Feature commit hash: ${hash_feature}"
83+ echo "hash_base=${hash_base}" >> $GITHUB_OUTPUT
84+ echo "hash_feature=${hash_feature}" >> $GITHUB_OUTPUT
85+ shell : bash
86+
5587 - name : Checkout main repo
5688 if : ${{ inputs.step == 'create-comment' }}
5789 uses : actions/checkout@v4
@@ -67,17 +99,22 @@ runs:
6799 echo "Config prefix: ${config_prefix}"
68100 echo "config_prefix=${config_prefix}" >> $GITHUB_OUTPUT
69101
70- # git diff config
71- rm -f ~/git_diff_config.txt
72- git_diff_config=$(git diff origin/${{ github.base_ref }}..origin/${{ github.head_ref }} -- ${{ inputs.snakemake_config }})
73- echo "Git diff config: ${git_diff_config}"
74- echo "git_diff_config=${git_diff_config}" >> ~/git_diff_config.txt
75102
76- # Assert variables found
77- if [[ -z $config_prefix ]]; then
78- echo "Error: Config prefix not found"
79- exit 1
80- fi
103+ # Get git diff of used snakemake config
104+ git_diff_config=$(git diff ${{ steps.env-variables-artifacts.outputs.hash_base }} ${{ steps.env-variables-artifacts.outputs.hash_feature }} -- ${{ inputs.snakemake_config }})
105+ # echo "GIT_DIFF_CONFIG='${git_diff_config}'" >> $GITHUB_ENV
106+ echo "GIT_DIFF_CONFIG<<EOF" >> $GITHUB_ENV
107+ echo "${git_diff_config}" >> $GITHUB_ENV
108+ echo "EOF" >> $GITHUB_ENV
109+ echo "git_diff_config:\n${git_diff_config}"
110+
111+ # Get the number of commits ahead of main
112+ behind_count=$(git rev-list --right-only --count ${{ steps.env-variables-artifacts.outputs.hash_feature }}...${{ steps.env-variables-artifacts.outputs.hash_base }})
113+ ahead_count=$(git rev-list --left-only --count ${{ steps.env-variables-artifacts.outputs.hash_feature }}...${{ steps.env-variables-artifacts.outputs.hash_base }})
114+ echo "BEHIND_COUNT=${behind_count}" >> $GITHUB_ENV
115+ echo "behind_count: ${behind_count}"
116+ echo "AHEAD_COUNT=${ahead_count}" >> $GITHUB_ENV
117+ echo "ahead_count: ${ahead_count}"
81118 shell : bash
82119
83120 - name : Checkout plot repo
@@ -88,32 +125,6 @@ runs:
88125 ref : ${{ github.event.repository.name }}
89126 ssh-key : ${{ inputs.repo_private_key }}
90127
91- - name : Download artifacts
92- if : ${{ inputs.step == 'create-comment' }}
93- uses : actions/download-artifact@v4
94-
95- - name : Get variables from artifacts
96- if : ${{ inputs.step == 'create-comment' }}
97- id : env-variables-artifacts
98- run : |
99- # Get compared hashes
100- hash_base=$(yq e '.metadata.hash_base' validator-metadata/validator-metadata.yml)
101- feature_commit_hash=$(yq e '.metadata.feature_commit_hash' validator-metadata/validator-metadata.yml)
102-
103- # Assert variables found
104- if [[ -z $hash_base || -z $feature_commit_hash ]]; then
105- echo "Error: Commit hashes not found"
106- exit 1
107- fi
108-
109- # Print and save variables
110- echo "Main commit hash: ${hash_base}"
111- echo "Feature commit hash: ${feature_commit_hash}"
112- echo "hash_base=${hash_base}" >> $GITHUB_OUTPUT
113- echo "hash_feature=${feature_commit_hash}" >> $GITHUB_OUTPUT
114-
115- shell : bash
116-
117128 - name : Upload relevant plots
118129 id : upload-plots
119130 if : ${{ inputs.step == 'create-comment' }}
@@ -128,8 +139,8 @@ runs:
128139 for plot in "${plots_array[@]}"
129140 do
130141 echo "Copying ${plot}"
131- cp -r "results (feature branch)/${{ steps.env-variables-repo.outputs.config_prefix }}/${plot}" "_validation-images/feature"
132- cp -r "results (base branch)/${{ steps.env-variables-repo.outputs.config_prefix }}/${plot}" "_validation-images/base"
142+ cp -r "$HOME/artifacts/ results (feature branch)/${{ steps.env-variables-repo.outputs.config_prefix }}/${plot}" "_validation-images/feature"
143+ cp -r "$HOME/artifacts/ results (base branch)/${{ steps.env-variables-repo.outputs.config_prefix }}/${plot}" "_validation-images/base"
133144 done
134145
135146 # Bot config
@@ -151,9 +162,6 @@ runs:
151162 git fetch origin
152163 git merge origin/main --allow-unrelated-histories
153164
154- git_diff_config=$(cat ~/git_diff_config.txt)
155- export GIT_DIFF_CONFIG=$(cat ~/git_diff_config.txt)
156-
157165 echo "${{ inputs.plots }}"
158166 pip install -r requirements.txt
159167 python draft_comment.py \
@@ -164,8 +172,8 @@ runs:
164172 --hash_base "${{ steps.env-variables-artifacts.outputs.hash_base }}" \
165173 --hash_feature "${{ steps.env-variables-artifacts.outputs.hash_feature }}" \
166174 --config_prefix "${{ steps.env-variables-repo.outputs.config_prefix }}" \
167- --dir_base "results (base branch)" \
168- --dir_feature "results (feature branch)" \
175+ --dir_base "$HOME/artifacts/ results (base branch)" \
176+ --dir_feature "$HOME/artifacts/ results (feature branch)" \
169177 --plots_hash ${{ steps.upload-plots.outputs.COMMIT_ID }} \
170178 --plots "${{ inputs.plots }}" \
171179 > comment.txt
0 commit comments