Skip to content

Commit 4b69501

Browse files
authored
Add integration test for CI and fix JuMP (#160)
1 parent 1416c01 commit 4b69501

File tree

2 files changed

+50
-3
lines changed

2 files changed

+50
-3
lines changed

.github/workflows/downstream.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: JuMP-integration
2+
on:
3+
push:
4+
branches: [master]
5+
pull_request:
6+
types: [opened, synchronize, reopened]
7+
jobs:
8+
test:
9+
name: Julia ${{ matrix.julia-version }} - ${{ matrix.package.repo }}
10+
runs-on: ${{ matrix.os }}
11+
strategy:
12+
matrix:
13+
julia-version: ['1.6', '1']
14+
os: ['ubuntu-latest']
15+
package:
16+
- {user: jump-dev, repo: JuMP.jl}
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: julia-actions/setup-julia@v1
20+
with:
21+
version: ${{ matrix.julia-version }}
22+
arch: x64
23+
- uses: julia-actions/julia-buildpkg@latest
24+
- name: Clone Downstream
25+
uses: actions/checkout@v2
26+
with:
27+
repository: ${{ matrix.package.user }}/${{ matrix.package.repo }}
28+
path: downstream
29+
- name: Load this and run the downstream tests
30+
shell: julia --color=yes --project=downstream {0}
31+
run: |
32+
using Pkg
33+
try
34+
# force it to use this PR's version of the package
35+
Pkg.develop(PackageSpec(path=".")) # resolver may fail with main deps
36+
Pkg.update()
37+
Pkg.test() # resolver may fail with test time deps
38+
catch err
39+
err isa Pkg.Resolve.ResolverError || rethrow()
40+
# If we can't resolve that means this is incompatible by SemVer and this is fine
41+
# It means we marked this as a breaking change, so we don't need to worry about
42+
# Mistakenly introducing a breaking change, as we have intentionally made one
43+
@info "Not compatible with this release. No problem." exception=err
44+
exit(0) # Exit immediately, as a success
45+
end

src/broadcast.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function broadcast_mutability(x, op, args::Vararg{Any,N}) where {N}
8989
return broadcast_mutability(typeof(x), op, typeof.(args)...)
9090
end
9191

92-
_checked_size(s, x::AbstractArray) = size(x) == s
92+
_checked_size(s, x::AbstractArray) = length(x) == s
9393
_checked_size(::Any, ::Any) = true
9494
_checked_size(::Any, ::Tuple{}) = true
9595
function _checked_size(s, x::Tuple)
@@ -102,13 +102,15 @@ end
102102
# happen during broadcasting since we'll either need to return a different size
103103
# to `x`, or multiple copies of an argument will be used for different parts of
104104
# `x`. To simplify, let's just return `IsNotMutable` if the sizes are different,
105-
# which will be slower but correct.
105+
# which will be slower but correct. This is slightly complicated by the fact
106+
# that some AbstractArray do not support `size`, so we check with `length`
107+
# instead. If the `size`s are different, a later error will be thrown.
106108
function broadcast_mutability(
107109
x::AbstractArray,
108110
op,
109111
args::Vararg{Any,N},
110112
) where {N}
111-
if !_checked_size(size(x), args)::Bool
113+
if !_checked_size(length(x), args)::Bool
112114
return IsNotMutable()
113115
end
114116
return broadcast_mutability(typeof(x), op, typeof.(args)...)

0 commit comments

Comments
 (0)