Deal with externals in crate builder check (#103)
* Simpler changed files detection * Fixes for crates with system dependencies * Checks for external crates * Detect need to update system repositories
This commit is contained in:
committed by
GitHub
parent
2511123b69
commit
9c10a433e4
@@ -8,7 +8,7 @@ on:
|
||||
jobs:
|
||||
|
||||
build:
|
||||
name: Build crate on ${{ matrix.os }}::${{ matrix.tag}}
|
||||
name: HOST:${{ matrix.os }} DOCK:${{ matrix.tag }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -41,7 +41,9 @@ jobs:
|
||||
- name: Check out alire-index
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 3 # Needed to be able to diff and obtain changed files
|
||||
fetch-depth: 10
|
||||
# Needed to be able to diff and obtain changed files. Changes beyond
|
||||
# that depth are not detected. Should be OK for crate submissions.
|
||||
|
||||
- name: Set up GNAT toolchain (FSF)
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
+68
-14
@@ -6,20 +6,24 @@ trap 'echo "Interrupted" >&2 ; exit 1' INT
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
|
||||
# get changes from second parent of this merge commit
|
||||
COMMIT=`git rev-list --parents -n1 HEAD | cut -f3 -d' '`
|
||||
echo COMMIT for diff is $COMMIT
|
||||
CHANGES=`git diff-tree --no-commit-id --name-only -r $COMMIT`
|
||||
# See whats happening
|
||||
git log --graph --decorate --pretty=oneline --abbrev-commit --all | head -30
|
||||
|
||||
# Detect changes
|
||||
CHANGES=$(git diff --name-only HEAD~1)
|
||||
|
||||
# Bulk changes for the record
|
||||
echo Changed files: $CHANGES
|
||||
|
||||
# Import the out-of-docker built alr
|
||||
export PATH+=:${PWD}/alire/bin
|
||||
|
||||
# Show alr metadata
|
||||
alr version
|
||||
|
||||
# Configure index
|
||||
alr index --name local --add ./index
|
||||
|
||||
# Bulk changes for the record
|
||||
echo Changed files: $CHANGES
|
||||
|
||||
# Test crate
|
||||
for file in $CHANGES; do
|
||||
|
||||
@@ -39,6 +43,7 @@ for file in $CHANGES; do
|
||||
fi
|
||||
|
||||
# Checks passed, this is a crate we must test
|
||||
list_exes=true # unless it's a system crate
|
||||
|
||||
crate=$(basename $file .toml)
|
||||
echo Testing crate: $crate
|
||||
@@ -53,19 +58,68 @@ for file in $CHANGES; do
|
||||
alr show --system $crate
|
||||
alr show --external --system $crate
|
||||
alr show --external-detect --system $crate
|
||||
crateinfo=$(alr show --external-detect --system $crate)
|
||||
|
||||
if $(alr show $crate --system | grep -q 'Available when: False'); then
|
||||
echo Skipping crate build: UNAVAILABLE on system
|
||||
echo CRATE DEPENDENCIES
|
||||
alr show --solve --detail --external-detect $crate
|
||||
solution=$(alr show --solve --detail --external-detect $crate)
|
||||
|
||||
# Skip on explicit unavailability
|
||||
if alr show --system $crate | grep -q 'Available when: False'; then
|
||||
echo SKIPPING crate build: UNAVAILABLE on system
|
||||
continue
|
||||
fi
|
||||
|
||||
echo BUILDING CRATE
|
||||
# In unsupported platforms, externals are properly reported as missing. We
|
||||
# can skip testing of such a crate since it will likely fail.
|
||||
if grep -q 'Dependencies (external):' <<< $solution ; then
|
||||
echo SKIPPING build for crate with MISSING external dependencies
|
||||
continue
|
||||
fi
|
||||
|
||||
# Update system repositories whenever a detected system package is involved,
|
||||
# either as dependency or as the crate being tested.
|
||||
if grep -iq 'origin: system' <<< $solution; then
|
||||
echo UPDATING system repositories...
|
||||
type apt-get 2>/dev/null && apt-get update || true
|
||||
type pacman 2>/dev/null && pacman -Syy || true
|
||||
else
|
||||
echo No need to update system repositories
|
||||
fi
|
||||
|
||||
# Alternatives for when the crate itself comes from an external. Only system
|
||||
# externals should be tested.
|
||||
if grep -q 'Origin: external path' <<< $crateinfo ; then
|
||||
echo SKIPPING detected external crate
|
||||
continue
|
||||
elif grep -q 'Origin: system package' <<< $crateinfo ; then
|
||||
echo INSTALLING detected system crate
|
||||
list_exes=false
|
||||
elif grep -q 'Not found:' <<< $crateinfo && \
|
||||
grep -q 'There are external definitions' <<< $crateinfo
|
||||
then
|
||||
echo SKIPPING undetected external crate
|
||||
continue
|
||||
fi
|
||||
|
||||
# Detect missing dependencies for clearer error
|
||||
if grep -q 'Dependencies cannot be met' <<< $solution ; then
|
||||
echo FAIL: crate dependencies cannot be met
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Actual checks
|
||||
echo DEPLOYING CRATE
|
||||
alr get --build -n $crate
|
||||
|
||||
echo LISTING EXECUTABLES
|
||||
cd ${crate}_*
|
||||
alr run --list
|
||||
cd ..
|
||||
if $list_exes; then
|
||||
echo LISTING EXECUTABLES
|
||||
cd ${crate}_*
|
||||
alr run --list
|
||||
cd ..
|
||||
else
|
||||
echo SKIPPING executable listing for system crate
|
||||
fi
|
||||
|
||||
echo CRATE BUILD ENDED SUCCESSFULLY
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user