Skip to content

Commit

Permalink
Fix reports-group & improve CI (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoanm authored Aug 30, 2024
1 parent c45e1cc commit d7248d3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 63 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/reusable-CI-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ name: 'CI reusable workflow'
on:
workflow_call:

env:
TEST_OUTPUT_STYLE: pretty
COMPOSER_OPTIONS: --optimize-autoloader

jobs:
coverage:
name: Go
Expand All @@ -30,7 +26,7 @@ jobs:

- name: Create coverage group
id: tests-coverage-group
uses: yoanm/temp-reports-group-workspace/gha-create@v0
uses: yoanm/temp-reports-group-workspace/create-group@v0
with:
format: clover
files: coverage.out
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/reusable-coverage-upload-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ jobs:
checks: write # For the check run creation !
steps:
- name: 'Check run ○'
uses: yoanm/temp-reports-group-workspace/gha-attach-check-run-to-triggering-workflow@v0
uses: yoanm/temp-reports-group-workspace/utils/attach-check-run-to-triggering-workflow@v0
with:
name: 'Fetch coverage info'
name: 'Fetch triggering workflow metadata'
fails-on-triggering-workflow-failure: true

- uses: yoanm/temp-reports-group-workspace/gha-fetch-workflow-metadata@v0
- uses: yoanm/temp-reports-group-workspace/utils/fetch-workflow-metadata@v0
id: fetch-workflow-metadata

outputs:
commit-sha: ${{ steps.fetch-workflow-metadata.outputs.commit-sha }}
run-id: ${{ steps.fetch-workflow-metadata.outputs.run-id }}
branch: ${{ steps.fetch-workflow-metadata.outputs.branch }}
pull-request: ${{ steps.fetch-workflow-metadata.outputs.pull-request }}

codacy-uploader:
name: Codacy
Expand All @@ -39,7 +41,7 @@ jobs:
secrets:
PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }}
with:
artifact: coverage-group
artifacts-pattern: coverage-group
run-id: ${{ needs.fetch-info.outputs.run-id }}
force-git-commit: ${{ needs.fetch-info.outputs.commit-sha }}
force-uploader-language: go
Expand All @@ -56,10 +58,10 @@ jobs:
secrets:
TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
artifact: coverage-group
artifacts-pattern: coverage-group
run-id: ${{ needs.fetch-info.outputs.run-id }}
force-git-commit: ${{ needs.fetch-info.outputs.commit-sha }}
force-git-branch: ${{ needs.fetch-info.outputs.branch }}
force-gh-pr: ${{ needs.fetch-info.outputs.pr-number }}
force-gh-pr: ${{ needs.fetch-info.outputs.pull-request }}
force-uploader-build: ${{ needs.fetch-info.outputs.run-id }}
force-uploader-build-url: ${{ needs.fetch-info.outputs.run-url }}
6 changes: 0 additions & 6 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ var (

errInputDirectoryDoesntExist = errors.New("input directory doesn't exist")
errRepositoryAlreadyImported = errors.New("repository already imported")

errPathIsNotADirectory = errors.New("path is not a directory")
)

func workspaceLoadingError(errList []error) error {
Expand Down Expand Up @@ -52,7 +50,3 @@ func alreadyImportedRepositoryError(repoName string, filepathList []string) erro
strings.Join(filepathList, ", "),
)
}

func pathIsNotADirectoryError(path string) error {
return fmt.Errorf("%w: %s", errPathIsNotADirectory, path)
}
35 changes: 0 additions & 35 deletions fshelper.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Debug | Template directory: templates
Debug | YAML anchor directory: yaml-anchors
Debug | Reading repository directory: config/repos
Debug | config/repos/unknown_file.txt is not a YAML template => ignored
Debug | config/unknown_file.txt is not a known file or directory => ignored
Debug | config/unknown_dir is not a known file or directory => ignored
Debug | config/unknown_file.txt is not a known file or directory => ignored
Debug | Reading template directory: templates
Debug | templates/test.unknown_template_type.yml is not a known template type => ignored
Debug | templates/unknown_file.txt is not a YAML template => ignored
Expand Down
25 changes: 15 additions & 10 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,19 @@ func readConfigDirectory(config *core.Config, rootPath string, decoderOpts []yam
}

var (
filenames []string
readErr error
files []os.DirEntry
readErr error
)

if filenames, readErr = readDirectory(rootPath); readErr != nil {
if files, readErr = os.ReadDir(rootPath); readErr != nil {
return configDirectoryLoadingError([]error{readErr})
}

filenames := make([]string, 0, len(files))
for _, file := range files {
filenames = append(filenames, file.Name())
}

return loadConfigDirectoryFiles(config, rootPath, decoderOpts, filenames)
}

Expand Down Expand Up @@ -164,7 +169,7 @@ func readRepositoryDirectory(
) (map[string]string, map[string]error) {
dirName := filepath.Base(rootPath)

filenames, readErr := readDirectory(rootPath)
files, readErr := os.ReadDir(rootPath)
if readErr != nil {
return nil, map[string]error{dirName: readErr}
}
Expand All @@ -174,10 +179,10 @@ func readRepositoryDirectory(

log.Debug().Msgf("Reading repository directory: %s", rootPath)

for _, filename := range filenames {
filePath := filepath.Join(rootPath, filename)
for _, file := range files {
filePath := filepath.Join(rootPath, file.Name())

ext := filepath.Ext(filename)
ext := filepath.Ext(file.Name())
if ext == ".yml" || ext == ".yaml" {
repoConfig, loadErr := core.LoadRepositoryFromFile(filePath, decoderOpts...)
if loadErr != nil {
Expand Down Expand Up @@ -205,14 +210,14 @@ func readTemplateDirectory(
return nil
}

dirContents, readErr := readDirectory(rootPath)
files, readErr := os.ReadDir(rootPath)
if readErr == nil {
log.Debug().Msgf("Reading template directory: %s", rootPath)

errList := map[string]error{}

for _, filename := range dirContents {
readTemplateDirectoryFile(config, filepath.Join(rootPath, filename), decoderOpts, errList)
for _, file := range files {
readTemplateDirectoryFile(config, filepath.Join(rootPath, file.Name()), decoderOpts, errList)
}

if len(errList) > 0 {
Expand Down

0 comments on commit d7248d3

Please sign in to comment.