-
Notifications
You must be signed in to change notification settings - Fork 246
ci: split build out of test workflow #2197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thompson-tomo
wants to merge
32
commits into
open-telemetry:main
Choose a base branch
from
thompson-tomo:build_splitOut
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
2e1e41a
Scaffold logic
thompson-tomo a1c24ac
Testing
thompson-tomo 50a24e9
Update ci-build-ruby.yml
thompson-tomo 5bc2775
fix
thompson-tomo 88ab871
Refactor gem selector
thompson-tomo 135d78c
Finish refactor
thompson-tomo ffa594a
fix
thompson-tomo 1cf487b
fix
thompson-tomo f5a58c6
lint
thompson-tomo f6f21cd
Fix the everything check
thompson-tomo 84b8a1c
Improve job output
thompson-tomo 208ea0e
Consolidate non label scenario
thompson-tomo 224541a
Update action.yml
thompson-tomo a9d4406
Typo fix
thompson-tomo a774374
Lint fix
thompson-tomo 18464e8
Use default value in array
thompson-tomo 601dabe
Add caching
thompson-tomo 62a44fa
Lint fix
thompson-tomo e384548
More cache changes
thompson-tomo daaf6c2
Finish cache
thompson-tomo ab2b0bf
update
thompson-tomo b8ea32b
update
thompson-tomo cab4903
Update ci-build-ruby.yml
thompson-tomo a2d8e9b
Update Rakefile
thompson-tomo 6bd293a
Update ci-build-ruby.yml
thompson-tomo 2ff8c93
Update Rakefile
thompson-tomo 60d786c
Update Workflow name
thompson-tomo 213b66c
Adds a verify to ensure builds have run
thompson-tomo 8979d68
Update ci-build-ruby.yml
thompson-tomo a01d95c
Update ci-build-ruby.yml
thompson-tomo ead4c98
Update ci-build-ruby.yml
thompson-tomo a20eb9c
Update ci-build-ruby.yml
thompson-tomo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Select Gems | ||
| description: Selects the Gems | ||
| inputs: | ||
| token: | ||
| description: Token used to add labels | ||
| required: false | ||
| type: string | ||
| default: | ||
| description: Gem string to be used if not able use pr label | ||
| required: false | ||
| type: string | ||
| default: "" | ||
| outputs: | ||
| gems: | ||
| description: The gems which have been changed | ||
| value: ${{steps.select.outputs.gems}} | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
|
|
||
| - uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1 | ||
| name: Calculate Gems | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| id: label | ||
| with: | ||
| repo-token: "${{ inputs.token }}" | ||
| sync-labels: true | ||
|
|
||
| - name: Select Gems | ||
| id: select | ||
| shell: bash | ||
| run: | | ||
| # Select Gems | ||
| default="${{ inputs.default }}" | ||
| deny='["ci", "deprecated"]' | ||
| labels="${{ steps.label.outputs.all-labels || inputs.default }}" | ||
| # labels is a comma-separated string, convert to JSON array | ||
| json=$(printf '%s\n' "$labels" | jq -R 'split(",")') | ||
|
|
||
| # Remove deny-listed items | ||
| filtered=$(echo "$json" | jq --argjson deny "$deny" '[ .[] | select(. as $l | $deny | index($l) | not) ]') | ||
|
|
||
| # Guarantee valid JSON by adding default | ||
| if [ -z "$filtered" ] || [ "$filtered" = "null" ] || [ "$(echo "$filtered" | jq 'length')" -eq 0 ]; then | ||
| filtered=$(jq -n --arg d "$default" '[ $d ]') | ||
| fi | ||
|
|
||
| { | ||
| echo "gems<<EOF" | ||
| echo "$filtered" | ||
| echo "EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - shell: bash | ||
| run: | | ||
| # Log Gems Selected | ||
| echo "Gems selected = ${{ steps.select.outputs.gems }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| name: Build / Source | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: &path_filters | ||
| - ".yardopts" | ||
| - "GEMFILE" | ||
| - "RAKEFILE" | ||
| - "**/.yardopts" | ||
| - "**/GEMFILE" | ||
| - "**/LICENSE" | ||
| - "**/RAKEFILE" | ||
| - "**/*.gemspec" | ||
| - "**/*.md" | ||
| - "**/lib/**" | ||
| - ".github/actions/select_gem/action.yml" | ||
| - ".github/workflows/ci-buid-ruby.yml" | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| paths: *path_filters | ||
| merge_group: | ||
|
|
||
|
thompson-tomo marked this conversation as resolved.
|
||
| jobs: | ||
| analyze: | ||
| runs-on: ubuntu-24.04 | ||
| outputs: | ||
| gems: ${{steps.select_gem.outputs.gems}} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - uses: ./.github/actions/select_gem | ||
| name: Select Gems | ||
| id: select_gem | ||
| with: | ||
| token: "${{ secrets.GITHUB_TOKEN }}" | ||
| default: "Everything" | ||
|
|
||
| build: | ||
| runs-on: ubuntu-24.04 | ||
| needs: analyze | ||
| if: ${{ needs.analyze.outputs.gems != '[]' }} | ||
| strategy: | ||
| matrix: | ||
| gem: ${{ fromJson(needs.analyze.outputs.gems) }} | ||
| fail-fast: false | ||
| name: ${{ matrix.gem }} | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| - name: Setup | ||
| if: ${{ matrix.gem != 'Everything' }} | ||
| id: setup | ||
| shell: bash | ||
| run: | | ||
| # 🛠️ Setup 🛠️ | ||
| dir=$(find . -iname 'opentelemetry-${{ matrix.gem }}.gemspec' -exec dirname {} \;) | ||
| echo "gem_dir=${dir}" >> $GITHUB_OUTPUT | ||
| - name: Install Ruby | ||
| uses: ruby/setup-ruby@e65c17d16e57e481586a6a5a0282698790062f92 # v1.300.0 | ||
| with: | ||
| ruby-version: "3.3.11" | ||
| - name: Compute Gemfile hash | ||
| id: lockhash | ||
| shell: bash | ||
| working-directory: ${{ steps.setup.outputs.gem_dir }} | ||
| run: | | ||
| files=$(find . -name "Gemfile" | sort) | ||
| if [[ -n "$files" ]]; then | ||
| hash=$(sha256sum $files | sha256sum | cut -d ' ' -f1) | ||
| echo "hash=$hash" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "hash=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT | ||
| fi | ||
| - name: Cache Bundler | ||
| uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 #v5.0.4 | ||
| with: | ||
| path: | | ||
| vendor/bundle | ||
| .bundle | ||
| ${{ steps.setup.outputs.gem_dir }}/vendor/bundle | ||
| ${{ steps.setup.outputs.gem_dir }}/.bundle | ||
| key: bundler-${{ runner.os }}-${{ matrix.gem }}-${{ steps.lockhash.outputs.hash }} | ||
| restore-keys: | | ||
| bundler-${{ runner.os }}-${{ matrix.gem }}- | ||
| - name: Install Tools & Gem Deps | ||
| run: | | ||
| # Always install tools | ||
| bundle config set path vendor/bundle | ||
| bundle config set clean false | ||
| bundle install --jobs 4 --retry 3 | ||
|
|
||
| # Conditionally install gem deps | ||
| if [ "${{ matrix.gem }}" = "Everything" ]; then | ||
| bundle exec rake install | ||
| fi | ||
| working-directory: "${{ steps.setup.outputs.gem_dir || '' }}" | ||
| - name: YARD | ||
| shell: bash | ||
| run: | | ||
| # 📄 Yard Docs 📄 | ||
| bundle exec rake yard | ||
| working-directory: "${{ steps.setup.outputs.gem_dir || '' }}" | ||
| - name: Build Gem | ||
| shell: bash | ||
| run: | | ||
| # 📦 Build Gem 📦 | ||
| bundle exec rake build | ||
| working-directory: "${{ steps.setup.outputs.gem_dir || '' }}" | ||
|
|
||
| verify: | ||
| runs-on: ubuntu-24.04 | ||
| needs: | ||
| - analyze | ||
| - build | ||
| if: ${{ always() }} # Always run so we can detect failures/skips | ||
| steps: | ||
| - name: Count builds | ||
| run: | | ||
| if [ "${{ needs.analyze.outputs.gems }}" = "[]" ]; then | ||
| echo "❌ No gems selected — build matrix was empty." | ||
| exit 1 | ||
| fi | ||
| gems='${{ needs.analyze.outputs.gems }}' | ||
| count=$(echo "$gems" | jq 'length') | ||
| echo "ℹ️ Build count: $count" | ||
|
|
||
| - name: Check build results | ||
| run: | | ||
| if [ "${{ needs.build.result }}" = "skipped" ]; then | ||
| echo "❌ Build job was skipped — no builds executed." | ||
| exit 1 | ||
| fi | ||
| if [ "${{ needs.build.result }}" != "success" ]; then | ||
| echo "❌ One or more builds failed." | ||
| exit 1 | ||
| fi | ||
| echo "✅ All builds ran and passed." | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.