diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index d0d0a4dcd..33726d2dd 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -24,7 +24,7 @@ on: branch: description: "Branch of chromebrew/chromebrew to run on, if different from this branch." required: false - update_merge_master: + update_rebase_to_master: description: "Update Branch." required: false type: boolean @@ -85,7 +85,7 @@ jobs: gh pr ready --undo || true # Try to update branch before building if a PR already # exists. - [[ "${{ ( inputs.update_merge_master ) }}" == 'true' ]] && gh pr update-branch || true + [[ "${{ ( inputs.update_rebase_to_master ) }}" == 'true' ]] && gh pr update-branch --rebase || true fi - name: Set Timestamp id: set-timestamp @@ -306,19 +306,6 @@ jobs: grep "Built and Uploaded:" /tmp/build.log || true echo "Deleting build output directories." sudo rm -rf release pkg_cache - - name: Add updated packages to branch. - id: push-check - run: | - if [ -n "$(git status --porcelain)" ]; then - git config user.name "${{ github.actor }}" - git config user.email "${{ github.actor }}@users.noreply.github.com" - git stash || true - git pull - git stash pop || true - git add -A - git commit -m "${{ inputs.branch || github.ref_name }}: Build Run on ${PLATFORM}." && git push - git log --oneline -10 - fi build-check: runs-on: ubuntu-24.04 needs: diff --git a/.github/workflows/Generate-PR.yml b/.github/workflows/Generate-PR.yml index ce7df11da..010ab2c17 100644 --- a/.github/workflows/Generate-PR.yml +++ b/.github/workflows/Generate-PR.yml @@ -12,7 +12,7 @@ on: pr_title: description: "Title of PR" required: false - update_merge_master: + update_rebase_to_master: description: "Update Branch." required: false type: boolean @@ -79,7 +79,7 @@ jobs: echo "Setting ${PR_NUMBER} to Draft while workflow runs." gh pr ready --undo || true fi - if [[ "${{ ( inputs.update_merge_master ) }}" == 'true' ]]; then + if [[ "${{ ( inputs.update_rebase_to_master ) }}" == 'true' ]]; then if [[ -n ${PR_NUMBER} ]]; then # Try to update branch immediately. gh pr update-branch || true @@ -89,7 +89,6 @@ jobs: # before continuing. gh pr update-branch || true fi - git pull fi - name: Get changed files id: changed-files @@ -317,10 +316,10 @@ jobs: git config user.name "${{ github.actor }}" git config user.email "${{ github.actor }}@users.noreply.github.com" git stash || true - git pull + git fetch origin ${{ inputs.branch || github.ref_name }} git stash pop || true git add -A - git commit -m "${{ inputs.branch || github.ref_name }}: Package File Update Run on ${PLATFORM} container." && git push + git commit -m "${{ inputs.branch || github.ref_name }}: Package File Update Run on ${PLATFORM} container." && git push origin ${{ inputs.branch || github.ref_name }} git log --oneline -10 fi build-check: @@ -353,13 +352,26 @@ jobs: sudo gem install ruby-libversion - name: Save git log id: save-git-log + env: + GH_TOKEN: ${{ secrets.CREW_PR_TOKEN }} run: | - git config user.name "${{ github.actor }}" - git config user.email "${{ github.actor }}@users.noreply.github.com" - git checkout master && git pull - git checkout "${{ inputs.branch || github.ref_name }}" - git log --oneline -10 - git log --oneline master..${{ inputs.branch || github.ref_name }} | grep -v "Merge branch 'master'\|Build Run on\|Package File Update Run on\|lint$" | tr '\n' '\0' | xargs -0 -n1 echo "- $*" >> /tmp/commits.txt + PR_NUMBER=$(gh pr list -L 1 -s open -H ${{ inputs.branch || github.ref_name }} | cut -f1) + if [[ -n ${PR_NUMBER} ]]; then + # Try to update branch immediately. + gh pr update-branch --rebase || true + else + gh pr create -d -b WIP -t "WIP ${{ inputs.branch || github.ref_name }}" + # Create a draft PR and immediately try to update the branch + # before continuing. + gh pr update-branch --rebase || true + fi + git config user.name "${{ github.actor }}" + git config user.email "${{ github.actor }}@users.noreply.github.com" + git checkout master && git fetch origin master + git checkout "${{ inputs.branch || github.ref_name }}" + # git rebase origin/master || git rebase --abort + git log --no-merges --oneline -10 + git log --no-merges --oneline master..${{ inputs.branch || github.ref_name }} | grep -v "Merge branch 'master'\|Build Run on\|Package File Update Run on\|lint$" | tr '\n' '\0' | xargs -0 -n1 echo "- $*" >> /tmp/commits.txt - name: Get changed files id: changed-files uses: tj-actions/changed-files@v47 @@ -377,7 +389,6 @@ jobs: - '!manifest/**' - '!packages/*.rb' - '!.github/**' - since_last_remote_commit: true - name: Get GH Token id: get_workflow_token uses: peter-murray/workflow-application-token-action@v4 @@ -474,7 +485,7 @@ jobs: gh pr edit --add-reviewer chromebrew/active $PR_EDIT_LABEL_FLAG --title "$(echo "${PR_TITLE}" | sed -e "s/^'//" -e "s/'$//") ${PKG_DELTAS}" -F /tmp/pr.txt fi # Try to update branch before finishing. - [[ "${{ ( inputs.update_merge_master ) }}" == 'true' ]] && gh pr update-branch || true + [[ "${{ ( inputs.update_rebase_to_master ) }}" == 'true' ]] && gh pr update-branch --rebase || true # Draft PRs can not be set to automerge. if [[ ${DRAFT_PR} == 'true' ]]; then gh pr ready --undo || true diff --git a/.github/workflows/Unit-Test.yml b/.github/workflows/Unit-Test.yml index 2205c5f48..f56437c6b 100644 --- a/.github/workflows/Unit-Test.yml +++ b/.github/workflows/Unit-Test.yml @@ -34,7 +34,7 @@ jobs: runner: ubuntu-24.04 runs-on: ${{ matrix.runner }} concurrency: - group: ${{ matrix.arch }}-${{ github.workflow }}-${{ github.ref }} + group: ${{ matrix.arch }}-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }} cancel-in-progress: true steps: - uses: actions/checkout@v4 diff --git a/.rubocop.yml b/.rubocop.yml index eadd9e9e6..9420551b6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -106,7 +106,7 @@ Metrics: # Many package names include - or _ and we don't want to lose that information by mistakenly converting into CamelCase. Naming/ClassAndModuleCamelCase: Exclude: - - 'packages/*' + - /**/packages/* # If there is meaningful information to convey about the contents of a heredoc, a comment is the best way to do it. # Forcing unique names for all heredoc delimiters does not improve documentation in the vast majority of cases. diff --git a/packages/py3_pyyaml.rb b/packages/py3_pyyaml.rb index fc2c6887c..3bff188cf 100644 --- a/packages/py3_pyyaml.rb +++ b/packages/py3_pyyaml.rb @@ -17,8 +17,8 @@ class Py3_pyyaml < Pip }) depends_on 'glibc' # R - depends_on 'libyaml' # R - depends_on 'python3' => :build + depends_on 'libyaml' => :build + depends_on 'python3' # R no_source_build end diff --git a/tools/getrealdeps.rb b/tools/getrealdeps.rb index e7bcb2577..c93c7daeb 100755 --- a/tools/getrealdeps.rb +++ b/tools/getrealdeps.rb @@ -1,5 +1,5 @@ #!/usr/local/bin/ruby -# getrealdeps version 2.2 (for Chromebrew) +# getrealdeps version 2.3 (for Chromebrew) # Author: Satadru Pramanik (satmandu) satadru at gmail dot com require 'fileutils' @@ -44,6 +44,8 @@ end # Write the missing dependencies to the package file. def write_deps(pkg_file, pkgdeps, pkg) + # pkg is not pkg.name in this function. + # e.g., pkg is Package::Py3_pyyaml # Add special deps for perl, pip, python, and ruby gem packages. case pkg.superclass.to_s when 'PERL' @@ -78,7 +80,7 @@ def write_deps(pkg_file, pkgdeps, pkg) puts "#{pkg.name}: #{exception[:exclusion_regex]} - #{exception[:comments]}..".orange if pkgdeps_length != pkgdeps.length end - puts "\nPackage #{pkg} has runtime library dependencies on these packages:".lightblue + puts "\nPackage #{pkg.name} has runtime library dependencies on these packages:".lightblue pkgdeps.each do |i| puts " depends_on '#{i}' # R".lightgreen end @@ -87,7 +89,7 @@ def write_deps(pkg_file, pkgdeps, pkg) missingpkgdeps = pkgdeps.reject { File.read(pkg_file).include?("depends_on '#{it}'") unless File.read(pkg_file).include?("depends_on '#{it}' => :build") } unless missingpkgdeps.empty? - puts "\nPackage file #{pkg}.rb is missing these runtime library dependencies:".orange + puts "\nPackage file #{pkg_file} is missing these runtime library dependencies:".orange puts " depends_on '#{missingpkgdeps.join("' # R\n depends_on '")}' # R".orange end @@ -143,10 +145,11 @@ def write_deps(pkg_file, pkgdeps, pkg) # Clean with rubocop. system "rubocop -c #{rubocop_config} -A #{pkg_file}" - FileUtils.cp pkg_file, "#{CREW_LOCAL_REPO_ROOT}/packages/#{pkg}.rb" unless CREW_LOCAL_REPO_ROOT.to_s.empty? + FileUtils.cp pkg_file, "#{CREW_LOCAL_REPO_ROOT}/packages/#{File.basename(pkg_file)}" unless CREW_LOCAL_REPO_ROOT.to_s.empty? end def main(pkg) + # pkg is pkg.name in this function. puts "Checking for the runtime dependencies of #{pkg}...".lightblue pkg_file = File.join(CREW_PACKAGES_PATH, "#{pkg}.rb") FileUtils.cp File.join(CREW_LOCAL_REPO_ROOT, "packages/#{pkg}.rb"), pkg_file if !CREW_LOCAL_REPO_ROOT.to_s.empty? && File.file?(File.join(CREW_LOCAL_REPO_ROOT, "packages/#{pkg}.rb"))