Skip to content

Commit

Permalink
extract directory name only if file is not removed and file is in ada…
Browse files Browse the repository at this point in the history
…pters directory

Commit updates the directoryExtractor function only if,
- file is not removed
- file belongs to the 'adapters' directory
  • Loading branch information
onkarvhanumante committed Sep 25, 2023
1 parent b9c2614 commit e606e18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/adapter-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
result-encoding: string
script: |
const utils = require('./.github/workflows/helpers/pull-request-utils.js')
function directoryExtractor(filepath) {
// extract directory name from filepath of the form adapters/<adapter-name>/*.go
if (filepath.startsWith("adapters/") && filepath.split("/").length > 2) {
function directoryExtractor(filepath, status) {
// extract directory name only if file is not removed and file is in adapters directory
if (status != "removed" && filepath.startsWith("adapters/") && filepath.split("/").length > 2) {
return filepath.split("/")[1]
}
return ""
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Run coverage tests
id: run_coverage
if: ${{ steps.get_directories.outputs.result }} != ""
if: steps.get_directories.outputs.result != ''
run: |
directories=$(echo '${{ steps.get_directories.outputs.result }}' | jq -r '.[]')
go mod download
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
repository: prebid/prebid-server

- name: Commit coverage files to coverage-preview branch
if: ${{ steps.run_coverage.outputs.coverage_dir }} != ""
if: steps.run_coverage.outputs.coverage_dir != ''
id: commit_coverage
run: |
directory=.github/preview/${{ github.run_id }}_$(date +%s)
Expand All @@ -88,11 +88,11 @@ jobs:
echo "remote_coverage_preview_dir=${directory}" >> $GITHUB_OUTPUT
- name: Checkout master branch
if: ${{ steps.get_directories.outputs.result }} != ""
if: steps.get_directories.outputs.result != ''
run: git checkout master

- name: Add coverage summary to pull request
if: ${{ steps.run_coverage.outputs.coverage_dir }} != "" && ${{ steps.commit_coverage.outputs.remote_coverage_preview_dir }} != ""
if: steps.run_coverage.outputs.coverage_dir != '' && steps.commit_coverage.outputs.remote_coverage_preview_dir != ''
uses: actions/github-script@v6
with:
script: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/helpers/pull-request-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ class diffHelper {
})

const directories = []
for (const { filename } of data) {
const directory = directoryExtractor(filename)
for (const { filename, status } of data) {
const directory = directoryExtractor(filename, status)
if (directory != "" && !directories.includes(directory)) {
directories.push(directory)
}
Expand Down

0 comments on commit e606e18

Please sign in to comment.