Add cargo display options to rust buildsystem. (#12309)

* Add cargo display options to rust buildsystem.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust Generate-PR workflow.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Adjust more workflows

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>
This commit is contained in:
chromebrew-actions[bot]
2025-07-31 02:19:57 -05:00
committed by GitHub
parent a06c42c587
commit 6c995408ba
4 changed files with 49 additions and 343 deletions

View File

@@ -291,162 +291,11 @@ jobs:
git commit -m "${{ inputs.branch || github.ref_name }}: Build Run on ${PLATFORM}." && git push
git log --oneline -10
fi
update-package-files:
strategy:
max-parallel: 1
matrix:
arch: [i686, x86_64, armv7l]
runner:
- ubuntu-24.04
- ubuntu-24.04-arm
exclude:
- arch: x86_64
runner: ubuntu-24.04-arm
- arch: i686
runner: ubuntu-24.04-arm
- arch: armv7l
runner: ubuntu-24.04
runs-on: ${{ matrix.runner }}
needs:
- setup
- generate
env:
CREW_REPO: ${{ github.event.repository.clone_url }}
CREW_BRANCH: ${{ inputs.branch || github.ref_name }}
TARGET_ARCH: ${{ matrix.arch }}
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
GLIBC_232_COMPATIBLE_PACKAGES: ${{ needs.setup.outputs.glibc_232_compat }}
GLIBC_237_COMPATIBLE_PACKAGES: ${{ needs.setup.outputs.glibc_237_compat }}
i686_PACKAGES: ${{ needs.setup.outputs.i686_packages }}
x86_64_PACKAGES: ${{ needs.setup.outputs.x86_64_packages }}
armv7l_PACKAGES: ${{ needs.setup.outputs.armv7l_packages }}
if: ${{ !cancelled() }}
concurrency:
group: ${{ matrix.arch }}-${{ github.workflow }}-${{ inputs.branch || github.ref_name }}
cancel-in-progress: true
steps:
- name: Fail if build jobs failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Export target docker container to github context
run: |
case $TARGET_ARCH in
x86_64)
echo "CONTAINER=satmandu/crew-pre-glibc-standalone:nocturne-x86_64.m90" >> "$GITHUB_ENV"
echo "PLATFORM=linux/amd64" >> "$GITHUB_ENV"
echo "LIB_SUFFIX=64" >> "$GITHUB_ENV"
;;
armv7l)
echo "CONTAINER=satmandu/crew-pre-glibc-standalone:fievel-armv7l.m91" >> "$GITHUB_ENV"
echo "PLATFORM=linux/arm/v7" >> "$GITHUB_ENV"
echo "LIB_SUFFIX=" >> "$GITHUB_ENV"
;;
i686)
# There is only one i686 container based upon M58 with glibc 2.23.
echo "CONTAINER=satmandu/crew-pre-glibc-standalone:alex-i686.m58" >> "$GITHUB_ENV"
echo "PLATFORM=linux/386" >> "$GITHUB_ENV"
echo "LIB_SUFFIX=" >> "$GITHUB_ENV"
;;
esac
- name: Run Updater in container
id: run-updater
if: ${{ contains(needs.*.result, 'failure') || !cancelled() }}
run: |
if [ "$PLATFORM" == 'linux/arm/v7' ] && [ -z "${armv7l_PACKAGES}" ]; then
# Exit the arm container if there are not armv7l compatible packages.
echo "Skipping armv7l container builds &/or package file updates"
exit 0
elif [ "$PLATFORM" == 'linux/amd64' ] && [ -z "${x86_64_PACKAGES}" ]; then
# Exit the x86_64 container if there are not x86_64 compatible packages.
echo "Skipping x86_64 container builds &/or package file updates"
exit 0
elif [ "$PLATFORM" == 'linux/386' ] && [ -z "${i686_PACKAGES}" ]; then
# Exit the i686 container if there are not i686 compatible packages.
echo "Skipping i686 container builds &/or package file updates"
exit 0
fi
git fetch origin
git checkout "${{ inputs.branch || github.ref_name }}"
git reset --hard "origin/${{ inputs.branch || github.ref_name }}"
git log --oneline -10
docker pull --platform "${PLATFORM}" "${CONTAINER}"
sudo apt install -y acl
# Detection of /output/pkg_cache dir triggers setting
# CREW_CACHE_DIR=1 and CREW_CACHE_ENABLED=1 in the build
# container. Without these, upload fails.
mkdir pkg_cache
sudo setfacl -R -m u:1000:rwx .
# See https://github.com/containerd/containerd/pull/7566#issuecomment-1461134737 for why we set ulimit.
docker run \
--rm \
--platform "${PLATFORM}" \
-e PUID=1000 \
-e PGID=1000 \
--privileged \
-e GCONV_PATH="/usr/local/lib${LIB_SUFFIX}/gconv" \
-e CREW_BUILD_NO_PACKAGE_FILE_HASH_UPDATES="${CREW_BUILD_NO_PACKAGE_FILE_HASH_UPDATES}" \
-e CREW_REPO="${CREW_REPO}" \
-e CREW_BRANCH="${{ inputs.branch || github.ref_name }}" \
-e GITLAB_TOKEN="${{ secrets.GITLAB_TOKEN }}" \
-e GITLAB_TOKEN_USERNAME="${{ secrets.GITLAB_TOKEN_USERNAME }}" \
-v "$(pwd)"/pkg_cache:/usr/local/tmp/packages:rshared \
-v "$(pwd)":/output:rshared \
--tmpfs /tmp \
--ulimit "nofile=$(ulimit -Sn):$(ulimit -Hn)" \
"${CONTAINER}" \
/bin/chromebrewstart "/output/tools/github_actions_update_builder_allowing_failures.sh" > >(tee -a /tmp/build.log) 2> >(tee -a /tmp/build.log >&2)
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 config pull.ff only
git stash || true
git pull
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 log --oneline -10
fi
build-check:
runs-on: ubuntu-24.04
needs:
- setup
- generate
- update-package-files
if: ${{ !cancelled() }}
steps:
- name: Fail if update or build jobs failed, otherwise create a PR
@@ -454,115 +303,10 @@ jobs:
run: exit 1
- name: Report update & build success
run: echo "Update & build jobs succeeded. Creating a PR."
- name: Get GH Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v4
with:
application_id: ${{ secrets.APPLICATION_ID }}
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }}
organization: chromebrew
revoke_token: true
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
ref: ${{ inputs.branch || github.ref_name }}
token: ${{ steps.get_workflow_token.outputs.token }}
- name: Rebase to master and save git log
id: rebase-and-git-log
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git fetch origin
git checkout "${{ inputs.branch || github.ref_name }}"
git reset --hard "origin/${{ inputs.branch || github.ref_name }}"
git pull --rebase origin master && git push -f
git log --oneline -10
git checkout master && git pull
git log --oneline master..${{ inputs.branch || github.ref_name }} | tr '\n' '\0' | xargs -0 -n1 echo "- $*" >> /tmp/commits.txt
git checkout "${{ inputs.branch || github.ref_name }}"
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
base_sha: master
files_yaml: |
manifest:
- manifest/**
packages:
- packages/*.rb
github:
- .github/**
other:
- ./**
- '!manifest/**'
- '!packages/*.rb'
- '!.github/**'
- name: Create Pull Request
- name: Trigger PR workflow
if: ${{ github.event.inputs.with_pr != 'No' }}
id: trigger-pr-workflow
env:
CHANGED_GITHUB_CONFIG_FILES: ${{ steps.changed-files.outputs.github_all_changed_files }}
CHANGED_MANIFEST_FILES: ${{ steps.changed-files.outputs.manifest_all_changed_files }}
CHANGED_OTHER_FILES: ${{ steps.changed-files.outputs.other_all_changed_files }}
CHANGED_PACKAGES: ${{ needs.setup.outputs.changed_packages }}
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
PR_TYPE: ${{ github.event.inputs.with_pr }}
TIMESTAMP: ${{ needs.setup.outputs.timestamp }}
i686_PACKAGES: ${{ needs.setup.outputs.i686_packages }}
x86_64_PACKAGES: ${{ needs.setup.outputs.x86_64_packages }}
armv7l_PACKAGES: ${{ needs.setup.outputs.armv7l_packages }}
GH_TOKEN: ${{ github.token }}
run: |
rm -rf /tmp/pr.txt
echo -e "## Description" >> /tmp/pr.txt
echo -e "- This PR was built using the Build.yml workflow, which was pointed to the ${{ inputs.branch || github.ref_name }} branch.\n" >> /tmp/pr.txt
echo -e "#### Commits:" >> /tmp/pr.txt
# Get git log from rebase-and-git-log step.
cat /tmp/commits.txt >> /tmp/pr.txt
if [[ "${CHANGED_GITHUB_CONFIG_FILES}" != "" ]]; then
echo -e "### Updated GitHub configuration files:" >> /tmp/pr.txt
for file in ${CHANGED_GITHUB_CONFIG_FILES}
do
echo "- ${file}" >> /tmp/pr.txt
done
fi
if [[ "${CHANGED_PACKAGES}" != "" ]]; then
echo -e "### Packages with Updated versions or Changed package files:" >> /tmp/pr.txt
for file in ${CHANGED_PACKAGES}
do
echo "- ${file}" >> /tmp/pr.txt
done
echo -e "##\nBuilds attempted for:" >> /tmp/pr.txt
[ -n "${x86_64_PACKAGES}" ] && echo -e "- [x] \`x86_64\`" >> /tmp/pr.txt
[ -n "${i686_PACKAGES}" ] && echo -e "- [x] \`i686\`" >> /tmp/pr.txt
[ -n "${armv7l_PACKAGES}" ] && echo -e "- [x] \`armv7l\`" >> /tmp/pr.txt
fi
if [[ "${CHANGED_OTHER_FILES}" != "" ]]; then
echo -e "### Other changed files:" >> /tmp/pr.txt
for file in ${CHANGED_OTHER_FILES}
do
echo "- ${file}" >> /tmp/pr.txt
done
fi
if [[ "${CHANGED_MANIFEST_FILES}" == "" ]]; then
echo -e "##\n- [x] This PR has no manifest .filelist changes. _(Package changes have neither added nor removed files.)_" >> /tmp/pr.txt
fi
echo -e "##\n### Run the following to get this pull request's changes locally for testing.\n\`\`\`bash" >> /tmp/pr.txt
echo -e "CREW_REPO=https://github.com/chromebrew/chromebrew.git CREW_BRANCH=${{ inputs.branch || github.ref_name }} crew update \\" >> /tmp/pr.txt
echo -e "&& yes | crew upgrade\n\`\`\`" >> /tmp/pr.txt
cat /tmp/pr.txt
[[ $PR_TYPE == 'Draft Pull Request' ]] && export PR_DRAFT_FLAG='-d'
if [[ -z ${PR_NUMBER} ]]; then
PR_NUMBER=$(gh pr create ${PR_DRAFT_FLAG} --reviewer chromebrew/active --title "${{ inputs.branch || github.ref_name }}: Build for ${CHANGED_PACKAGES}" -F /tmp/pr.txt | rev | cut -d"/" -f1 | rev)
else
gh pr edit --title "${{ inputs.branch || github.ref_name }}: Build for ${CHANGED_PACKAGES}" -F /tmp/pr.txt
fi
# Draft PRs can not be set to automerge.
if [[ PR_TYPE == 'Draft Pull Request' ]]; then
gh pr ready --undo || true
else
gh pr merge --auto || true
fi
echo "PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=${PR_NUMBER}" >> "$GITHUB_ENV"
# Trigger workflow run:
gh workflow run Unit-Test.yml ${PR_NUMBER}
gh workflow -R chromebrew/chromebrew run Generate-PR.yml -f branch="${{ inputs.branch || github.ref_name }}" -f draft_pr="${{ github.event.inputs.with_pr == 'Draft Pull Request' }}"

View File

@@ -15,9 +15,6 @@ jobs:
update-check:
if: ${{ github.repository_owner == 'chromebrew' }}
runs-on: ubuntu-24.04
outputs:
timestamp: ${{ steps.set-variables.outputs.TIMESTAMP }} # https://stackoverflow.com/a/75142892
update_branch_name: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
steps:
- uses: actions/checkout@v4
with:
@@ -38,82 +35,43 @@ jobs:
make -j "$(nproc)"
sudo make install
sudo gem install ruby-libversion
- name: Set workflow & branch variables
id: set-variables
run: |
export TIMESTAMP="$(date -u +%F-%H-%M)"
export UPDATE_BRANCH_NAME="automatic-updates-${TIMESTAMP}"
echo "TIMESTAMP=${TIMESTAMP}" >> "$GITHUB_OUTPUT"
echo "UPDATE_BRANCH_NAME=${UPDATE_BRANCH_NAME}" >> "$GITHUB_OUTPUT"
- name: Git setup
env:
UPDATE_BRANCH_NAME: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
run: |
git pull && ( git checkout -b "${UPDATE_BRANCH_NAME}" || git checkout "${UPDATE_BRANCH_NAME}" )
- name: Check for updates in pip packages.
id: pip-update-checks
env:
UPDATE_BRANCH_NAME: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
run: |
git pull
git stash drop || true
LD_LIBRARY_PATH=/usr/local/lib ruby tools/update_python_pip_packages.rb
# Create a new branch with the updated package files only
# if there are updated packages. Otherwise exit early.
if [ -n "$(git status --porcelain)" ]; then
echo "Python pip packages were updated."
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add -A
git commit -m "Add unbuilt updated pip packages to ${UPDATE_BRANCH_NAME}"
echo "PIP_UPDATED=true" >> "$GITHUB_OUTPUT"
else
echo "Python pip packages were not updated."
echo "PIP_UPDATED=false" >> "$GITHUB_OUTPUT"
fi
- name: Push pip package changes
if: ${{ steps.pip-update-checks.outputs.PIP_UPDATED == 'true' }}
uses: ad-m/github-push-action@master
with:
branch: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
export TIMESTAMP="$(date -u +%F-%H-%M)"
for i in $(git status --porcelain | awk '{print $2}' | grep ^packages/)
do
git stash pop || true
git add $i
pkg=${i%.rb}
pkg=${pkg#packages/}
git checkout -b "${pkg}-${TIMESTAMP}" || git checkout "${pkg}-${TIMESTAMP}"
git commit -m "Add unbuilt ${pkg} to ${pkg}-${TIMESTAMP}"
git push
gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${pkg}-${TIMESTAMP}"
git stash || true
git checkout master
done
- name: Check for updates in ruby gem packages.
id: gem-update-checks
env:
UPDATE_BRANCH_NAME: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
run: |
git pull
git stash drop || true
LD_LIBRARY_PATH=/usr/local/lib ruby tools/update_ruby_gem_packages.rb
# Create a new branch with the updated package files only
# if there are updated packages. Otherwise exit early.
if [ -n "$(git status --porcelain)" ]; then
echo "Ruby gem packages were updated."
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add -A
git commit -m "Add unbuilt updated ruby gem packages to ${UPDATE_BRANCH_NAME}"
echo "GEM_UPDATED=true" >> "$GITHUB_OUTPUT"
else
echo "Ruby gem packages were not updated."
echo "GEM_UPDATED=false" >> "$GITHUB_OUTPUT"
fi
- name: Push ruby gem package changes
if: ${{ steps.gem-update-checks.outputs.GEM_UPDATED == 'true' }}
uses: ad-m/github-push-action@master
with:
branch: ${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}
- name: Cancel if no updates
id: no-update-cancel
if: ${{ ( steps.pip-update-checks.outputs.PIP_UPDATED == 'false' ) && ( steps.gem-update-checks.outputs.GEM_UPDATED == 'false' ) }}
run: |
echo "PIP_UPDATED is ${{ steps.pip-update-checks.outputs.PIP_UPDATED }}."
echo "GEM_UPDATED is ${{ steps.gem-update-checks.outputs.GEM_UPDATED }}."
git checkout master && git branch -D "${{ steps.set-variables.outputs.UPDATE_BRANCH_NAME }}" && git push
# https://stackoverflow.com/a/75809743
gh run cancel "${{ github.run_id }}"
gh run watch "${{ github.run_id }}"
dispatch-build:
if: ${{ github.repository_owner == 'chromebrew' }}
runs-on: ubuntu-24.04
needs: update-check
env:
UPDATE_BRANCH_NAME: ${{ needs.update-check.outputs.update_branch_name }}
steps:
- name: gh_workflow_dispatch
run: gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${UPDATE_BRANCH_NAME}"
export TIMESTAMP="$(date -u +%F-%H-%M)"
for i in $(git status --porcelain | awk '{print $2}' | grep ^packages/)
do
git stash pop || true
git add $i
pkg=${i%.rb}
pkg=${pkg#packages/}
git checkout -b "${pkg}-${TIMESTAMP}" || git checkout "${pkg}-${TIMESTAMP}"
git commit -m "Add unbuilt ${pkg} to ${pkg}-${TIMESTAMP}"
git push
gh workflow -R chromebrew/chromebrew run Build.yml -f branch="${pkg}-${TIMESTAMP}"
git stash || true
git checkout master
done

View File

@@ -9,10 +9,12 @@ class RUST < Package
@rustflags = "#{ENV.fetch('RUSTFLAGS', nil)} #{@rust_flags}"
rust_env =
{
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil),
RUSTFLAGS: @rustflags
CARGO_TERM_COLOR: 'always',
CARGO_TERM_PROGRESS_WHEN: 'always',
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil),
RUSTFLAGS: @rustflags
}.transform_keys(&:to_s)
@channel_flag = @rust_channel.to_s.empty? ? '' : "+#{@rust_channel}"
@@ -41,10 +43,12 @@ class RUST < Package
def self.install
rust_env =
{
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil),
RUSTFLAGS: @rustflags
CARGO_TERM_COLOR: 'always',
CARGO_TERM_PROGRESS_WHEN: 'always',
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil),
RUSTFLAGS: @rustflags
}.transform_keys(&:to_s)
@rust_install_path.split.each do |path|

View File

@@ -4,7 +4,7 @@ require 'etc'
require 'open3'
OLD_CREW_VERSION ||= defined?(CREW_VERSION) ? CREW_VERSION : '1.0'
CREW_VERSION ||= '1.63.7' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
CREW_VERSION ||= '1.63.8' unless defined?(CREW_VERSION) && CREW_VERSION == OLD_CREW_VERSION
# Kernel architecture.
KERN_ARCH ||= Etc.uname[:machine]