Skip to content

refactor: standardize GitHub Actions with consistent environment handling#34

Merged
mikolaj-matuszny-ext-sonarsource merged 4 commits intomasterfrom
feat/mmatuszny/BUILD-8672-standarization
Aug 1, 2025
Merged

refactor: standardize GitHub Actions with consistent environment handling#34
mikolaj-matuszny-ext-sonarsource merged 4 commits intomasterfrom
feat/mmatuszny/BUILD-8672-standarization

Conversation

@mikolaj-matuszny-ext-sonarsource
Copy link
Copy Markdown
Contributor

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource commented Aug 1, 2025

Summary

This PR standardizes all GitHub Actions build scripts with consistent environment variable handling, improved parameter validation, and comprehensive documentation.

Key Changes

🔄 Environment Variable Standardization

  • Unified PULL_REQUEST environment variable format across all actions: ${{ github.event.pull_request.number || '' }}
  • Added missing PULL_REQUEST_SHA and DEFAULT_BRANCH environment variables to all build actions
  • Standardized branch detection with consistent helper functions

⚙️ Action Configuration Improvements

  • Added repox-url input parameter to all build actions (default: https://repox.jfrog.io)
  • Added develocity-url input parameter to Maven builds (default: https://develocity.sonar.build/)
  • Removed redundant required: true from parameters with default values (GitHub Actions best practice)

🔍 Parameter Validation & Documentation

  • Enhanced parameter validation using "${VAR:?}" syntax across all build scripts
  • Comprehensive documentation of all environment variables with examples
  • Consistent script headers and validation patterns matching build-maven standard

🧪 Test Coverage & Quality

  • Added test coverage for previously untested helper functions
  • Updated spec files to match standardized behavior
  • All shell tests passing: 136 examples, 0 failures total

📚 Documentation Updates

  • Updated README with new input parameters and latest configurations
  • Corrected terminology from "master/main" to "default branch" for consistency

Test Results

All build actions tested successfully:

  • ✅ build-maven: 21 examples, 0 failures
  • ✅ build-gradle: 32 examples, 0 failures
  • ✅ build-npm: 29 examples, 0 failures
  • ✅ build-yarn: 35 examples, 0 failures
  • ✅ build-poetry: 19 examples, 0 failures

Back to 100% coverage - added missing tests for Poetry and Gradle.

Breaking Changes

None - all changes are backward compatible with existing workflows.

Migration Guide

No migration required. Existing workflows will continue to work with the new defaults.

…ling

- Standardize PULL_REQUEST environment variable usage across all actions
- Add missing PULL_REQUEST_SHA and DEFAULT_BRANCH environment variables
- Add repox-url and develocity-url inputs with proper defaults
- Remove redundant required: true from parameters with defaults
- Update build scripts with standardized helper functions
- Improve parameter validation and documentation consistency
- Add comprehensive test coverage for untested functions
- Update README with latest action configurations and improvements
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource marked this pull request as ready for review August 1, 2025 09:37
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Aug 1, 2025

🤖 Pull Request summary

Updates build scripts to standardize branch terminology and improve environment variable handling.

Main changes:
Terminology standardization: Replace "main/master branch" references with "default branch" across all build systems
Environment variable consistency: Standardize PULL_REQUEST and PULL_REQUEST_SHA handling across Gradle, NPM, Maven, Poetry, and Yarn builds
Input validation improvements: Make ARTIFACTORY_URL required and remove redundant required: false declarations from action.yml files
Code refactoring: Extract branch type detection into reusable helper functions (is_default_branch, is_maintenance_branch, etc.)

Review focus areas:

  • Verify the PULL_REQUEST environment variable changes don't break existing workflows - the logic shifted from conditional assignment to expecting pre-set values
  • Check that making ARTIFACTORY_URL required won't cause issues for consumers who previously relied on

💬 Please send your feedback

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Comment thread README.md
Comment thread build-gradle/build.sh
Comment thread build-npm/build.sh
Comment thread build-npm/build.sh
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.

GITHUB_SHA, GITHUB_OUTPUT validation is missing
ARTIFACTORY_ACCESS_TOKEN, GITHUB_EVENT_NAME, MAVEN_LOCAL_REPOSITORY description is missing
seems that MAVEN_LOCAL_REPOSITORY is missing an export, for the case when it's set with a default value

@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource merged commit d2f2c24 into master Aug 1, 2025
12 checks passed
@mikolaj-matuszny-ext-sonarsource mikolaj-matuszny-ext-sonarsource deleted the feat/mmatuszny/BUILD-8672-standarization branch August 1, 2025 10:17
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