mirror of
https://github.com/apple/container.git
synced 2026-09-26 09:35:37 +00:00
fix(common.yml): globalize CURRENT_SDK, improve shell safety and imp… (#178)
## 🔧 Improvements Summary This PR introduces three improvements focused on safety, maintainability, and readability of the GitHub Actions workflow. --- ### 1. Define Global Environment Variable **Before:** Environment variable `CURRENT_SDK` was defined repeatedly in multiple steps. **After:** Declared in gloabally one time. #### Why This Matters: - Eliminates duplication across steps. - Makes it easier to update or remove the variable in the future. - Still allows per-step override when necessary. ### 2. Fix Unsafe Shell Conditional on inputs.release - Using **[[ ... ]]** **instea**d of **[ ... ]** for conditionals. - Adding **double quotes** around inputs and refs to **avoid** evaluation issues. **PREVIOUSLY FIXED** Containerization project. [https://github.com/apple/containerization/pull/68](url) ### 3. Removed EXCLUSION AND TODO comment. #### Affected Steps: `check Formatting` `make proto` ### Improvements: Now that the repositories are public, we no longer need to exclude files like Package.swift and Package.resolved from formatting and proto checks. - Removed EXCLUDES logic - Removed related TODO comments - Updated git diff checks to include all files @wlan0 @katiewasnothere
This commit is contained in:
@@ -16,64 +16,79 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
env:
|
||||
CURRENT_SDK: y
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Update containerization
|
||||
run: |
|
||||
/usr/bin/swift package update containerization
|
||||
|
||||
- name: Check formatting
|
||||
run: |
|
||||
./scripts/install-hawkeye.sh
|
||||
make fmt
|
||||
if ! git diff --quiet -- . ':(exclude)Package.swift' ':(exclude)Package.resolved'; then echo "The following files require formatting or license header updates:\n$(git diff --name-only)" ; false ; fi
|
||||
|
||||
if ! git diff --quiet -- . ; then
|
||||
echo "❌ The following files require formatting or license header updates:"
|
||||
git diff --name-only -- .
|
||||
false
|
||||
fi
|
||||
|
||||
- name: Check protobuf
|
||||
run: |
|
||||
make protos
|
||||
|
||||
# TODO [launch]: TEMPORARILY we need to exclude these files since we had to modify them to add
|
||||
# the github token for pulling the private repos.
|
||||
if ! git diff --quiet -- . ':(exclude)Package.swift' ':(exclude)Package.resolved' ':(exclude)Protobuf.Makefile'; then echo "The following files require formatting or license header updates:\n$(git diff --name-only)" ; false ; fi
|
||||
env:
|
||||
CURRENT_SDK: y
|
||||
if ! git diff --quiet -- . ; then
|
||||
echo "❌ The following files require formatting or license header updates:"
|
||||
git diff --name-only -- .
|
||||
false
|
||||
fi
|
||||
|
||||
- name: Set build configuration
|
||||
run: |
|
||||
echo "BUILD_CONFIGURATION=debug" >> $GITHUB_ENV
|
||||
if [ ${{ inputs.release }} == true ]; then
|
||||
if [[ "${{ inputs.release }}" == "true" ]]; then
|
||||
echo "BUILD_CONFIGURATION=release" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Make the container project and docs
|
||||
run: |
|
||||
make container dsym docs
|
||||
tar cfz _site.tgz _site
|
||||
env:
|
||||
DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer"
|
||||
CURRENT_SDK: y
|
||||
|
||||
- name: Create package
|
||||
run: |
|
||||
mkdir -p outputs
|
||||
mv bin/${{ env.BUILD_CONFIGURATION }}/container-installer-unsigned.pkg outputs
|
||||
mv bin/${{ env.BUILD_CONFIGURATION }}/bundle/container-dSYM.zip outputs
|
||||
|
||||
- name: Test the container project
|
||||
run: |
|
||||
launchctl setenv HTTP_PROXY $HTTP_PROXY
|
||||
make test cleancontent install-kernel integration
|
||||
env:
|
||||
DEVELOPER_DIR: "/Applications/Xcode_16.3.app/Contents/Developer"
|
||||
CURRENT_SDK: y
|
||||
CURRENT_SDK: y # explicitly repeated due to local env block
|
||||
|
||||
- name: Save documentation artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: api-docs
|
||||
path: "./_site.tgz"
|
||||
retention-days: 14
|
||||
|
||||
- name: Save package artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: container-package
|
||||
path: ${{ github.workspace }}/outputs
|
||||
|
||||
uploadPages:
|
||||
# Separate upload step required because upload-pages-artifact needs
|
||||
# gtar which is not on the macOS runner.
|
||||
@@ -84,13 +99,16 @@ jobs:
|
||||
steps:
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v5
|
||||
|
||||
- name: Download a single artifact
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: api-docs
|
||||
|
||||
- name: Add API docs to documentation
|
||||
run: |
|
||||
tar xfz _site.tgz
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user