-
Notifications
You must be signed in to change notification settings - Fork 26
Teams for file paths #130
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
Merged
Merged
Teams for file paths #130
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5218224
providng a for-file verbose option
perryqh 2fc2900
extracting ForFileOutputBuilder for clarity
perryqh 32651dc
bump version
perryqh ac651f3
teams_for_file optimization
perryqh fdc1776
caching file_path teams on team_names_for_files
perryqh 5af6d2e
bumping codeowners-rs
perryqh 1511acc
bumping to 0.2.17 even though it is not released so I do not forget
perryqh e8b9154
adding for_file_from_codeowners
perryqh 014d4a7
allow raise predicate
perryqh 72268ed
updating code_ownership docs
perryqh 15217d7
no cache checkout
perryqh 2480661
smoke test code_ownership cd
perryqh 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 |
|---|---|---|
| @@ -1,130 +1,184 @@ | ||
| --- | ||
| name: CD | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| tags: ["v*"] | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| ci-data: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| result: ${{ steps.fetch.outputs.result }} | ||
| steps: | ||
| - id: fetch | ||
| uses: oxidize-rb/actions/fetch-ci-data@v1 | ||
| with: | ||
| supported-ruby-platforms: | | ||
| # Excluding: | ||
| # `arm-linux`: Cranelift doesn't support 32-bit architectures | ||
| # `x64-mingw32`: `x64-mingw-ucrt` should be used for Ruby 3.1+ (https://github.com/rake-compiler/rake-compiler-dock?tab=readme-ov-file#windows) | ||
| # 3.0 is deprecated as stable ruby version according to: | ||
| # https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb#L54 | ||
| exclude: [arm-linux, x64-mingw32] | ||
| stable-ruby-versions: | | ||
| exclude: [head] | ||
|
|
||
| build: | ||
| name: Build native gems | ||
| needs: ci-data | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: "3.4" | ||
|
|
||
| - uses: oxidize-rb/actions/cross-gem@v1 | ||
| id: cross-gem | ||
| with: | ||
| platform: ${{ matrix.ruby-platform }} | ||
| ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }} | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cross-gem-${{ matrix.ruby-platform }} | ||
| path: pkg/*-${{ matrix.ruby-platform }}.gem | ||
| if-no-files-found: error | ||
|
|
||
| - name: Smoke gem install | ||
| if: matrix.ruby-platform == 'ignore-for-now-x86_64-linux' # GitHub actions architecture | ||
| run: | | ||
| gem install pkg/fast_code_owners-*.gem --verbose | ||
| script="puts FastCodeOwners::VERSION" | ||
| ruby -rfast_code_owners -e "$script" | grep 0.1.0 | ||
| echo "✅ Successfully gem installed" | ||
|
|
||
| release: | ||
| name: Release | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | ||
| with: | ||
| ruby-version: "3.4" | ||
| bundler-cache: true | ||
| cargo-cache: true | ||
| cache-version: v1 | ||
|
|
||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: cross-gem-* | ||
| merge-multiple: true | ||
| path: pkg/ | ||
|
|
||
| - name: Package source gem | ||
| run: bundle exec rake pkg:ruby | ||
|
|
||
| - name: Ensure version matches the tag | ||
| run: | | ||
| GEM_VERSION=$(grep -Eo "[0-9]+\.[0-9]+\.[0-9]+[-0-9]*" lib/code_ownership/version.rb | head -n 1) | ||
| if [ "v$GEM_VERSION" != "${{ github.ref_name }}" ]; then | ||
| echo "Gem version does not match tag" | ||
| echo " v$GEM_VERSION != ${{ github.ref_name }}" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Push Gem | ||
| working-directory: pkg/ | ||
| env: | ||
| GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
| run: | | ||
| mkdir -p $HOME/.gem | ||
| touch $HOME/.gem/credentials | ||
| chmod 0600 $HOME/.gem/credentials | ||
| printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
| ls -l | ||
| for i in *.gem; do | ||
| if [ -f "$i" ]; then | ||
| if ! gem push "$i" >push.out; then | ||
| gemerr=$? | ||
| sed 's/^/::error:: /' push.out | ||
| if ! grep -q "Repushing of gem" push.out; then | ||
| exit $gemerr | ||
| fi | ||
| name: CD | ||
|
|
||
| on: | ||
| workflow_call: | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| ci-data: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| result: ${{ steps.fetch.outputs.result }} | ||
| steps: | ||
| - id: fetch | ||
| uses: oxidize-rb/actions/fetch-ci-data@v1 | ||
| with: | ||
| supported-ruby-platforms: | | ||
| # Excluding: | ||
| # `arm-linux`: Cranelift doesn't support 32-bit architectures | ||
| # `x64-mingw32`: `x64-mingw-ucrt` should be used for Ruby 3.1+ (https://github.com/rake-compiler/rake-compiler-dock?tab=readme-ov-file#windows) | ||
| # `x64-mingw-ucrt`: Rust target not available in rake-compiler-dock | ||
| # `aarch64-linux-musl`: Rust target not available in rake-compiler-dock | ||
| # 3.0 is deprecated as stable ruby version according to: | ||
| # https://github.com/oxidize-rb/actions/blob/main/fetch-ci-data/evaluate.rb#L54 | ||
| exclude: [arm-linux, x64-mingw32, x64-mingw-ucrt, aarch64-linux-musl] | ||
| stable-ruby-versions: | | ||
| exclude: [head] | ||
|
|
||
| build: | ||
| name: Build native gems | ||
| needs: ci-data | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ruby-platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: "3.4" | ||
|
|
||
| - uses: oxidize-rb/actions/cross-gem@v1 | ||
| id: cross-gem | ||
| with: | ||
| platform: ${{ matrix.ruby-platform }} | ||
| ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }} | ||
| cache-save-always: false | ||
| cargo-cache-clean: false # Add this to disable cargo-cache usage | ||
| env: | ||
| # Add a unique identifier to prevent cache conflicts | ||
| ACTIONS_CACHE_KEY_SUFFIX: "-${{ matrix.ruby-platform }}-${{ github.run_id }}" | ||
|
|
||
| - uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: cross-gem-${{ matrix.ruby-platform }} | ||
| path: pkg/*-${{ matrix.ruby-platform }}.gem | ||
| if-no-files-found: error | ||
| retention-days: 30 # Keep artifacts for 30 days | ||
|
|
||
| - name: Smoke test gem install | ||
| if: matrix.ruby-platform == 'x86_64-linux' # Enable for Linux x64 | ||
| run: | | ||
| # Install the platform-specific gem | ||
| gem install pkg/code_ownership-*-${{ matrix.ruby-platform }}.gem --verbose | ||
|
|
||
| # Test that it works | ||
| ruby -e "require 'code_ownership'; puts 'Version: ' + CodeOwnership::VERSION" | ||
|
|
||
| # Run a simple functionality test | ||
| ruby -e "require 'code_ownership'; CodeOwnership.file_owner_team_names('lib/code_ownership.rb')" || true | ||
|
|
||
| echo "✅ Successfully tested ${{ matrix.ruby-platform }} gem" | ||
|
|
||
| release: | ||
| name: Release | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write # Required for creating releases | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 | ||
| with: | ||
| ruby-version: "3.4" | ||
| bundler-cache: true | ||
| cargo-cache: false | ||
|
|
||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| pattern: cross-gem-* | ||
| merge-multiple: true | ||
| path: pkg/ | ||
|
|
||
| - name: Package source gem | ||
| run: bundle exec rake pkg:ruby | ||
|
|
||
| - name: Push Gem | ||
| id: push-gem | ||
| working-directory: pkg/ | ||
| env: | ||
| GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
| run: | | ||
| set -e # Exit on error | ||
|
|
||
| # Setup credentials | ||
| mkdir -p $HOME/.gem | ||
| touch $HOME/.gem/credentials | ||
| chmod 0600 $HOME/.gem/credentials | ||
| printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials | ||
|
|
||
| # List all gems to be pushed | ||
| echo "📦 Gems to be pushed:" | ||
| ls -la *.gem | ||
|
|
||
| # Extract version from the Ruby version file | ||
| GEM_VERSION=$(ruby -r ../lib/code_ownership/version.rb -e "puts CodeOwnership::VERSION") | ||
| echo "gem_version=${GEM_VERSION}" >> $GITHUB_OUTPUT | ||
| echo "🏷️ Detected gem version: ${GEM_VERSION}" | ||
|
|
||
| # Track results | ||
| NEW_VERSION=false | ||
| PUSHED_GEMS=() | ||
| SKIPPED_GEMS=() | ||
|
|
||
| for i in *.gem; do | ||
| if [ -f "$i" ]; then | ||
| echo "⏳ Attempting to push $i..." | ||
| if ! gem push "$i" >push.out 2>&1; then | ||
| gemerr=$? | ||
| if grep -q "Repushing of gem" push.out; then | ||
| echo "⏭️ Gem $i already exists on RubyGems, skipping..." | ||
| SKIPPED_GEMS+=("$i") | ||
| else | ||
| echo "❌ Failed to push $i:" | ||
| cat push.out | ||
| exit $gemerr | ||
| fi | ||
| else | ||
| echo "✅ Successfully pushed $i" | ||
| PUSHED_GEMS+=("$i") | ||
| NEW_VERSION=true | ||
| fi | ||
| done | ||
|
|
||
| - name: Create GitHub release | ||
| uses: ncipollo/release-action@v1 | ||
| with: | ||
| allowUpdates: true | ||
| generateReleaseNotes: true | ||
| draft: true | ||
| omitBodyDuringUpdate: true | ||
| omitNameDuringUpdate: true | ||
| omitPrereleaseDuringUpdate: true | ||
| skipIfReleaseExists: true | ||
| fi | ||
| done | ||
|
|
||
| # Summary | ||
| echo "📊 Push Summary:" | ||
| echo " - Pushed: ${#PUSHED_GEMS[@]} gems" | ||
| echo " - Skipped: ${#SKIPPED_GEMS[@]} gems" | ||
|
|
||
| # Set outputs | ||
| echo "new_version=${NEW_VERSION}" >> $GITHUB_OUTPUT | ||
| echo "pushed_count=${#PUSHED_GEMS[@]}" >> $GITHUB_OUTPUT | ||
| echo "skipped_count=${#SKIPPED_GEMS[@]}" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Create GitHub Release | ||
| if: ${{ steps.push-gem.outputs.new_version == 'true' }} | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| # Create release with more detailed information | ||
| RELEASE_NOTES="## CodeOwnership v${{ steps.push-gem.outputs.gem_version }} | ||
|
|
||
| ### 📦 Published Gems | ||
| - Source gem: code_ownership-${{ steps.push-gem.outputs.gem_version }}.gem | ||
| - Platform gems: Published for all supported platforms | ||
|
|
||
| ### 🎯 Supported Platforms | ||
| $(ls pkg/*.gem | grep -E '\-(x86|arm|aarch)' | sed 's/.*-\([^-]*\)\.gem/- \1/') | ||
|
|
||
| --- | ||
| " | ||
|
|
||
| gh release create "v${{ steps.push-gem.outputs.gem_version }}" \ | ||
| --title "v${{ steps.push-gem.outputs.gem_version }}" \ | ||
| --notes "$RELEASE_NOTES" \ | ||
| --generate-notes \ | ||
| pkg/*.gem | ||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual kickoff (for now).