From 8d606706e2851588bc99b382265902a610523149 Mon Sep 17 00:00:00 2001 From: Kaj Kowalski Date: Fri, 7 Nov 2025 07:26:21 +0100 Subject: [PATCH] chore(tooling): Improve CI pipeline and expand pre-commit hooks Expands the pre-commit configuration with a wider range of hooks to enforce file quality, validation, security, and Git safety checks. The CI pipeline is updated to: - Correct the `golangci-lint` format command to `fmt`. - Enable CGO for test execution to support the race detector. - Improve the robustness of test report parsing scripts. Additionally, this commit includes minor stylistic and formatting cleanups across various project files. --- .github/CODEOWNERS | 2 +- .github/workflows/autofix.yml | 2 +- .github/workflows/ci.yml | 20 +- .github/workflows/codeql.yml | 208 +++++++++--------- .gitignore | 158 ++++++------- .pre-commit-config.yaml | 21 ++ AGENTS.md | 4 +- Dockerfile | 2 +- Dockerfile.dev | 2 +- README.md | 18 +- Taskfile.yml | 6 +- internal/exporters/html.go | 2 +- ...tml_template.html => html_template.gohtml} | 0 internal/exporters/output.md | 5 +- scripts/build.ps1 | 18 +- scripts/build.sh | 2 +- 16 files changed, 245 insertions(+), 225 deletions(-) rename internal/exporters/{html_template.html => html_template.gohtml} (100%) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 52f5664..48ee87e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ # These owners will be the default owners for everything in -# the repo. Unless a later match takes precedence, they will +# the repo. Unless a later match takes precedence, they will # be requested for review when someone opens a pull request. * @kjanat diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 3e5eed3..f597f82 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -34,7 +34,7 @@ jobs: run: golangci-lint run --fix - name: Run golangci-lint format - run: golangci-lint format + run: golangci-lint fmt - name: Run go mod tidy run: go mod tidy diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2a3392d..b1a861d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,8 @@ jobs: - name: Run tests with enhanced reporting id: test + env: + CGO_ENABLED: 1 run: | cat >> $GITHUB_STEP_SUMMARY << EOF ## 🔧 Test Environment @@ -79,9 +81,9 @@ jobs: # Extract test results for summary TEST_STATUS=$? TOTAL_TESTS=$(grep -c "=== RUN" test-output.log || echo "0") - PASSED_TESTS=$(grep -c "--- PASS:" test-output.log || echo "0") - FAILED_TESTS=$(grep -c "--- FAIL:" test-output.log || echo "0") - SKIPPED_TESTS=$(grep -c "--- SKIP:" test-output.log || echo "0") + PASSED_TESTS=$(grep -c -- "--- PASS:" test-output.log || echo "0") + FAILED_TESTS=$(grep -c -- "--- FAIL:" test-output.log || echo "0") + SKIPPED_TESTS=$(grep -c -- "--- SKIP:" test-output.log || echo "0") # Generate test summary cat >> $GITHUB_STEP_SUMMARY << EOF @@ -120,7 +122,7 @@ jobs: ### ❌ Failed Tests Details ``` EOF - grep -A 10 "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY + grep -A 10 -- "--- FAIL:" test-output.log | head -100 >> $GITHUB_STEP_SUMMARY cat >> $GITHUB_STEP_SUMMARY << 'EOF' ``` @@ -128,12 +130,10 @@ jobs: fi # Set outputs for other steps - cat >> $GITHUB_OUTPUT << EOF - test-status=$TEST_STATUS - total-tests=$TOTAL_TESTS - passed-tests=$PASSED_TESTS - failed-tests=$FAILED_TESTS - EOF + echo "test-status=$TEST_STATUS" >> $GITHUB_OUTPUT + echo "total-tests=$TOTAL_TESTS" >> $GITHUB_OUTPUT + echo "passed-tests=$PASSED_TESTS" >> $GITHUB_OUTPUT + echo "failed-tests=$FAILED_TESTS" >> $GITHUB_OUTPUT # Exit with the original test status exit $TEST_STATUS diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 6299e32..10c8e95 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,104 +1,104 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -# This workflow is configured to be called by other workflows for more controlled execution -# This allows integration with the main CI pipeline and avoids redundant runs -# To enable automatic execution, uncomment the triggers below: -on: - workflow_call: - schedule: - - cron: '44 16 * * 6' - # push: - # branches: [ "master" ] - # pull_request: - # branches: [ "master" ] - -jobs: - analyze: - name: Analyze (${{ matrix.language }}) - # Runner size impacts CodeQL analysis time. To learn more, please see: - # - https://gh.io/recommended-hardware-resources-for-running-codeql - # - https://gh.io/supported-runners-and-hardware-resources - # - https://gh.io/using-larger-runners (GitHub.com only) - # Consider using larger runners or machines with greater resources for possible analysis time improvements. - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} - permissions: - # required for all workflows - security-events: write - - # required to fetch internal or private CodeQL packs - packages: read - - # only required for workflows in private repositories - actions: read - contents: read - - strategy: - fail-fast: false - matrix: - include: - - language: actions - build-mode: none - - language: go - build-mode: autobuild - # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' - # Use `c-cpp` to analyze code written in C, C++ or both - # Use 'java-kotlin' to analyze code written in Java, Kotlin or both - # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both - # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, - # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. - # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how - # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - # Add any setup steps before running the `github/codeql-action/init` action. - # This includes steps like installing compilers or runtimes (`actions/setup-node` - # or others). This is typically only required for manual builds. - # - name: Setup runtime (example) - # uses: actions/setup-example@v1 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - languages: ${{ matrix.language }} - build-mode: ${{ matrix.build-mode }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - - # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs - # queries: security-extended,security-and-quality - - # If the analyze step fails for one of the languages you are analyzing with - # "We were unable to automatically build your code", modify the matrix above - # to set the build mode to "manual" for that language. Then modify this step - # to build your code. - # â„šī¸ Command-line programs to run using the OS shell. - # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun - - if: matrix.build-mode == 'manual' - shell: bash - run: | - echo 'If you are using a "manual" build mode for one or more of the' \ - 'languages you are analyzing, replace this with the commands to build' \ - 'your code, for example:' - echo ' make bootstrap' - echo ' make release' - exit 1 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 - with: - category: "/language:${{matrix.language}}" +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +# This workflow is configured to be called by other workflows for more controlled execution +# This allows integration with the main CI pipeline and avoids redundant runs +# To enable automatic execution, uncomment the triggers below: +on: + workflow_call: + schedule: + - cron: '44 16 * * 6' + # push: + # branches: [ "master" ] + # pull_request: + # branches: [ "master" ] + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: actions + build-mode: none + - language: go + build-mode: autobuild + # CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + # Add any setup steps before running the `github/codeql-action/init` action. + # This includes steps like installing compilers or runtimes (`actions/setup-node` + # or others). This is typically only required for manual builds. + # - name: Setup runtime (example) + # uses: actions/setup-example@v1 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 + with: + category: "/language:${{matrix.language}}" diff --git a/.gitignore b/.gitignore index 0627806..fd64c00 100644 --- a/.gitignore +++ b/.gitignore @@ -1,79 +1,79 @@ -# Created by https://www.toptal.com/developers/gitignore/api/go -# Edit at https://www.toptal.com/developers/gitignore?templates=go - -### Go ### -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib - -# Test binary, built with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file -go.work - -# End of https://www.toptal.com/developers/gitignore/api/go - -# Shit -.github/TODO - -# Local test files -output/ -outputs/ -articulate-sample.json -test-output.* -go-os-arch-matrix.csv -test_godocx.go -test_input.json - -# Build artifacts -build/ - -# Old workflows -.github/workflows/ci-old.yml -.github/workflows/ci-enhanced.yml - -# Test coverage files -coverage.out -coverage.txt -coverage.html -coverage.* -coverage -*.cover -*.coverprofile -main_coverage - -# Other common exclusions -*.exe -*.exe~ -*.dll -*.so -*.dylib -*.test -*.out -/tmp/ -.github/copilot-instructions.md - -# Editors -.vscode/ -.idea/ - -.task/ - -**/*.local.* - -.claude/ - -NUL +# Created by https://www.toptal.com/developers/gitignore/api/go +# Edit at https://www.toptal.com/developers/gitignore?templates=go + +### Go ### +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work + +# End of https://www.toptal.com/developers/gitignore/api/go + +# Shit +.github/TODO + +# Local test files +output/ +outputs/ +articulate-sample.json +test-output.* +go-os-arch-matrix.csv +test_godocx.go +test_input.json + +# Build artifacts +build/ + +# Old workflows +.github/workflows/ci-old.yml +.github/workflows/ci-enhanced.yml + +# Test coverage files +coverage.out +coverage.txt +coverage.html +coverage.* +coverage +*.cover +*.coverprofile +main_coverage + +# Other common exclusions +*.exe +*.exe~ +*.dll +*.so +*.dylib +*.test +*.out +/tmp/ +.github/copilot-instructions.md + +# Editors +.vscode/ +.idea/ + +.task/ + +**/*.local.* + +.claude/ + +NUL diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 66a4eb6..f7f39ca 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,10 +4,31 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: + # File quality - id: trailing-whitespace + exclude: '^\.github/ISSUE_TEMPLATE/.*\.yml$' - id: end-of-file-fixer + - id: mixed-line-ending + args: ['--fix=lf'] + + # File validation - id: check-yaml + - id: check-json + - id: check-toml + + # Security + - id: detect-private-key + + # Git safety + - id: check-merge-conflict + - id: check-case-conflict + - id: no-commit-to-branch + args: ['--branch=master', '--branch=main'] + + # File structure - id: check-added-large-files + - id: check-symlinks + - id: check-executables-have-shebangs - repo: https://github.com/golangci/golangci-lint rev: v2.6.1 hooks: diff --git a/AGENTS.md b/AGENTS.md index 4f5eb1b..3c471bb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,8 +4,8 @@ - **Build**: `task build` or `go build -o bin/articulate-parser main.go` - **Run tests**: `task test` or `go test -race -timeout 5m ./...` - **Run single test**: `go test -v -race -run ^TestName$ ./path/to/package` -- **Test with coverage**: - - `task test:coverage` or +- **Test with coverage**: + - `task test:coverage` or - `go test -race -coverprofile=coverage/coverage.out -covermode=atomic ./...` - **Lint**: `task lint` (runs vet, fmt check, staticcheck, golangci-lint) - **Format**: `task fmt` or `gofmt -s -w .` diff --git a/Dockerfile b/Dockerfile index 59b938e..b365d8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ ARG BUILD_TIME ARG GIT_COMMIT # Docker buildx automatically provides these for multi-platform builds ARG BUILDPLATFORM -ARG TARGETPLATFORM +ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT diff --git a/Dockerfile.dev b/Dockerfile.dev index 47e34b9..4cfe848 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -30,7 +30,7 @@ ARG BUILD_TIME ARG GIT_COMMIT # Docker buildx automatically provides these for multi-platform builds ARG BUILDPLATFORM -ARG TARGETPLATFORM +ARG TARGETPLATFORM ARG TARGETOS ARG TARGETARCH ARG TARGETVARIANT diff --git a/README.md b/README.md index fc2fbfb..752dcfc 100644 --- a/README.md +++ b/README.md @@ -20,36 +20,36 @@ A Go-based parser that converts Articulate Rise e-learning content to various fo flowchart TD %% User Input CLI[Command Line Interface
main.go] --> APP{App Service
services/app.go} - + %% Core Application Logic APP --> |"ProcessCourseFromURI"| PARSER[Course Parser
services/parser.go] APP --> |"ProcessCourseFromFile"| PARSER APP --> |"exportCourse"| FACTORY[Exporter Factory
exporters/factory.go] - + %% Data Sources PARSER --> |"FetchCourse"| API[Articulate Rise API
rise.articulate.com] PARSER --> |"LoadCourseFromFile"| FILE[Local JSON File
*.json] - + %% Data Models API --> MODELS[Data Models
models/course.go] FILE --> MODELS MODELS --> |Course, Lesson, Item| APP - + %% Export Factory Pattern FACTORY --> |"CreateExporter"| MARKDOWN[Markdown Exporter
exporters/markdown.go] FACTORY --> |"CreateExporter"| HTML[HTML Exporter
exporters/html.go] FACTORY --> |"CreateExporter"| DOCX[DOCX Exporter
exporters/docx.go] - + %% HTML Cleaning Service CLEANER[HTML Cleaner
services/html_cleaner.go] --> MARKDOWN CLEANER --> HTML CLEANER --> DOCX - + %% Output Files MARKDOWN --> |"Export"| MD_OUT[Markdown Files
*.md] HTML --> |"Export"| HTML_OUT[HTML Files
*.html] DOCX --> |"Export"| DOCX_OUT[Word Documents
*.docx] - + %% Interfaces (Contracts) IPARSER[CourseParser Interface
interfaces/parser.go] -.-> PARSER IEXPORTER[Exporter Interface
interfaces/exporter.go] -.-> MARKDOWN @@ -64,7 +64,7 @@ flowchart TD classDef output fill:#fce7f3,stroke:#be185d,stroke-width:2px,color:#be185d classDef interface fill:#ecfdf5,stroke:#16a34a,stroke-width:1px,stroke-dasharray: 5 5,color:#16a34a classDef service fill:#cffafe,stroke:#0891b2,stroke-width:2px,color:#0891b2 - + class CLI userInput class APP,FACTORY coreLogic class API,FILE,MODELS dataSource @@ -80,7 +80,7 @@ The system follows **Clean Architecture** principles with clear separation of co - **đŸŽ¯ Entry Point**: Command-line interface handles user input and coordinates operations - **đŸ—ī¸ Application Layer**: Core business logic with dependency injection -- **📋 Interface Layer**: Contracts defining behavior without implementation details +- **📋 Interface Layer**: Contracts defining behavior without implementation details - **🔧 Service Layer**: Concrete implementations of parsing and utility services - **📤 Export Layer**: Factory pattern for format-specific exporters - **📊 Data Layer**: Domain models representing course structure diff --git a/Taskfile.yml b/Taskfile.yml index 46fc761..5cdde73 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -316,13 +316,13 @@ tasks: docker:run: desc: Run Docker container aliases: [dr] - deps: [docker:build] + deps: ['docker:build'] cmds: - docker run --rm {{.APP_NAME}}:{{.VERSION}} --help docker:test: desc: Test Docker image - deps: [docker:build] + deps: ['docker:build'] cmds: - docker run --rm {{.APP_NAME}}:{{.VERSION}} --version - echo "Docker image tested successfully" @@ -434,7 +434,7 @@ tasks: docs:coverage: desc: Open coverage report in browser - deps: [test:coverage] + deps: ['test:coverage'] cmds: - '{{if eq OS "darwin"}}open {{.COVERAGE_DIR}}/coverage.html{{else if eq OS "windows"}}start {{.COVERAGE_DIR}}/coverage.html{{else}}xdg-open {{.COVERAGE_DIR}}/coverage.html 2>/dev/null || echo "Please open {{.COVERAGE_DIR}}/coverage.html in your browser"{{end}}' diff --git a/internal/exporters/html.go b/internal/exporters/html.go index f35781e..e3391d1 100644 --- a/internal/exporters/html.go +++ b/internal/exporters/html.go @@ -15,7 +15,7 @@ import ( //go:embed html_styles.css var defaultCSS string -//go:embed html_template.html +//go:embed html_template.gohtml var htmlTemplate string // HTMLExporter implements the Exporter interface for HTML format. diff --git a/internal/exporters/html_template.html b/internal/exporters/html_template.gohtml similarity index 100% rename from internal/exporters/html_template.html rename to internal/exporters/html_template.gohtml diff --git a/internal/exporters/output.md b/internal/exporters/output.md index be78d86..e855c50 100644 --- a/internal/exporters/output.md +++ b/internal/exporters/output.md @@ -4,9 +4,8 @@ Course description ## Course Information -- **Course ID**: +- **Course ID**: - **Share ID**: example-id -- **Navigation Mode**: +- **Navigation Mode**: --- - diff --git a/scripts/build.ps1 b/scripts/build.ps1 index eb3ce1d..99396cd 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -137,7 +137,7 @@ try { # Show targets and exit if requested if ($ShowTargets) { Write-Host 'Available build targets:' -ForegroundColor Cyan - + # Get available platforms and architectures from Go toolchain try { $GoTargets = @(go tool dist list 2>$null) @@ -148,7 +148,7 @@ try { Write-Host 'âš ī¸ Could not retrieve targets from Go. Using default targets.' -ForegroundColor Yellow $PlatformList = $Platforms.Split(',') | ForEach-Object { $_.Trim() } $ArchList = $Architectures.Split(',') | ForEach-Object { $_.Trim() } - + foreach ($platform in $PlatformList) { foreach ($arch in $ArchList) { $BinaryName = "articulate-parser-$platform-$arch" @@ -163,12 +163,12 @@ try { $SelectedTargets = @() $PlatformList = $Platforms.Split(',') | ForEach-Object { $_.Trim() } $ArchList = $Architectures.Split(',') | ForEach-Object { $_.Trim() } - + foreach ($target in $GoTargets) { $parts = $target.Split('/') $platform = $parts[0] $arch = $parts[1] - + if ($PlatformList -contains $platform -and $ArchList -contains $arch) { $SelectedTargets += @{ Platform = $platform @@ -177,14 +177,14 @@ try { } } } - + # Display filtered targets foreach ($target in $SelectedTargets) { $BinaryName = "articulate-parser-$($target.Platform)-$($target.Arch)" if ($target.Platform -eq 'windows') { $BinaryName += '.exe' } Write-Host " $($target.Original) -> $BinaryName" -ForegroundColor Gray } - + # Show all available targets if verbose if ($VerboseOutput) { Write-Host "`nAll Go targets available on this system:" -ForegroundColor Cyan @@ -404,13 +404,13 @@ try { } $BuildArgs += '-o' $BuildArgs += $Target.Path - + # If using custom entry point that's not main.go # we need to use the file explicitly to avoid duplicate declarations $EntryPointPath = Join-Path $ProjectRoot $EntryPoint $EntryPointFile = Split-Path $EntryPointPath -Leaf $IsCustomEntryPoint = ($EntryPointFile -ne 'main.go') - + if ($IsCustomEntryPoint) { # When using custom entry point, compile only that file $BuildArgs += $EntryPointPath @@ -419,7 +419,7 @@ try { $PackagePath = Split-Path $EntryPointPath -Parent $BuildArgs += $PackagePath } - + # For verbose output, show the command that will be executed if ($VerboseOutput) { Write-Host "Command: go $($BuildArgs -join ' ')" -ForegroundColor DarkCyan diff --git a/scripts/build.sh b/scripts/build.sh index d0739ad..f6e53f0 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -73,7 +73,7 @@ EXAMPLES: DEFAULT TARGETS: Operating Systems: darwin, freebsd, linux, windows Architectures: amd64, arm64 - + This creates 8 binaries total (4 OS × 2 ARCH) GO BUILD FLAGS: