Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1275 #1277

Merged
merged 32 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c4ec013
issue#1275
stefjoosten Feb 8, 2022
6e6ced6
Releasenotes
hanjoosten Feb 8, 2022
53522bf
Fix issue 1275
hanjoosten Feb 8, 2022
48f6218
replace vpatterns by instanceList
hanjoosten Feb 8, 2022
7ab9985
move testcase
hanjoosten Feb 8, 2022
4ea4983
cabal file
hanjoosten Feb 8, 2022
1e44cbd
Enable --validate check on github for regression test
hanjoosten Feb 9, 2022
39d92eb
Comment out the global setting to Barracuda, for it is the default now.
hanjoosten Feb 11, 2022
438d994
comment out innodb_large_prefix setting
hanjoosten Feb 12, 2022
af53739
somewhere there is a bracket mismatch
hanjoosten Feb 12, 2022
6590e2c
Only drop database if it exists to prevent error
hanjoosten Feb 13, 2022
7508fc5
Better diagnostic output
hanjoosten Feb 13, 2022
ed308c5
ignore deletion of table if it doesn't exist
hanjoosten Feb 13, 2022
3c8ee22
Enable weeder and hlint (ubuntu only)
hanjoosten Feb 13, 2022
de25cd7
fix syntax error (because newer PHP version ?)
hanjoosten Feb 13, 2022
a2c6b71
remove weeder from build-and-test-windows
hanjoosten Feb 13, 2022
2b5a88a
fix PHP code
hanjoosten Feb 13, 2022
22379d8
minor move weeder/hlint
hanjoosten Feb 14, 2022
45fe0fc
force error on MacOS
hanjoosten Feb 14, 2022
751e0a7
ensure all same version of stack-action
hanjoosten Feb 14, 2022
ed54118
restore database connection
hanjoosten Feb 14, 2022
9f55d96
repair bug introduced in commit e2b7e63ed2021539ff483b0cbd679503a71a3ee1
hanjoosten Feb 14, 2022
33c2c1f
Add diagnostics (temporary)
hanjoosten Feb 16, 2022
7a28be0
Don't inspect table before it exists
hanjoosten Feb 16, 2022
aa06088
Revert "Add diagnostics (temporary)"
hanjoosten Feb 16, 2022
b3c3a5a
More diagnostic output
hanjoosten Feb 16, 2022
0e015be
show the expression in output
hanjoosten Feb 16, 2022
046ee64
Remove BOM
hanjoosten Feb 16, 2022
1e604ea
No need to have a special case for EDcI ONE
hanjoosten Feb 18, 2022
7030e29
Minor clean up
hanjoosten Feb 18, 2022
bd74dca
Fix utf8-related bug
hanjoosten Feb 18, 2022
3a3c254
Another UTF8 related fix
hanjoosten Feb 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 69 additions & 56 deletions .github/workflows/ci2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,103 +6,116 @@ on:
- "**" # Only trigger on branches (i.e. not tags, ..)

jobs:
hlint:
name: Check for code sanity with hlint
runs-on: ubuntu-latest
steps:
- name: Checkout project contents 📡
uses: actions/checkout@v2
- name: Setup hlint
uses: rwe/actions-hlint-setup@v1
- name: Run hlint
uses: rwe/actions-hlint-run@v2

build-and-test-docker:
name: Build with Docker
runs-on: ubuntu-latest
env:
DOCKER_AMPERSAND_IMAGE: ampersandtarski/ampersand
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Prepare for docker
run: |
echo Running on branch ${GITHUB_REF##*/}
docker version
- name: Prepare for docker
run: |
echo Running on branch ${GITHUB_REF##*/}
docker version

- name: Build final image
run: docker build . --tag ${DOCKER_AMPERSAND_IMAGE}:latest --build-arg GIT_SHA=${{ github.sha }} --build-arg GIT_Branch=${{ github.ref }}
- name: Build final image
run: docker build . --tag ${DOCKER_AMPERSAND_IMAGE}:latest --build-arg GIT_SHA=${{ github.sha }} --build-arg GIT_Branch=${{ github.ref }}

# For main branch push latest to DockerHub
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push latest
if: github.ref == 'refs/heads/main'
run: docker push ${DOCKER_AMPERSAND_IMAGE}:latest
# For main branch push latest to DockerHub
- name: Login to DockerHub
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Push latest
if: github.ref == 'refs/heads/main'
run: docker push ${DOCKER_AMPERSAND_IMAGE}:latest

build-and-test-ubuntu:
name: Build and test on ubuntu-latest 🏗 🧪
runs-on: ubuntu-latest
steps:
-
name: Checkout project contents 📡
- name: Checkout project contents 📡
uses: actions/checkout@v2
-
name: Use cache when available 📦
- name: Use cache when available 📦
uses: freckle/stack-cache-action@main
-
name: Build and test 🏗 🧪
uses: freckle/stack-action@main # stack-action does all these steps: dependencies, build, test.
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
stack-arguments: '--copy-bins --flag ampersand:buildAll'
weeder: true # TODO: Re-enable. See https://github.com/AmpersandTarski/Ampersand/issues/1225
hlint: true
mysql-version: "mariadb-10.6"
- name: Build and test 🏗 🧪
uses: freckle/stack-action@v3 # stack-action does all these steps: dependencies, build, test.
with:
stack-arguments: "--copy-bins --flag ampersand:buildAll"
- name: Check weeds🌿🌿🌿
uses: freckle/stack-action@v1
with:
weeder: true

build-and-test-macOS:
name: Build and test on macOS 🏗 🧪
runs-on: macos-latest
steps:
-
name: Checkout project contents 📡
- name: Checkout project contents 📡
uses: actions/checkout@v2
-
name: Use cache when available 📦
- name: Use cache when available 📦
uses: freckle/stack-cache-action@main
-
name: Build and test 🏗 🧪
uses: freckle/stack-action@main
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "mariadb-10.6"
- name: Build and test 🏗 🧪
uses: freckle/stack-action@v3
with:
stack-arguments: '--copy-bins --flag ampersand:buildAll'
weeder: false
hlint: true
stack-arguments: "--copy-bins --flag ampersand:buildAll"
- name: Check weeds🌿🌿🌿
uses: freckle/stack-action@v1
with:
weeder: true

build-and-test-windows:
name: Build and test on Windows 🏗 🧪
runs-on: windows-latest
steps:
-
name: Checkout project contents 📡
- name: Checkout project contents 📡
uses: actions/checkout@v2
-
name: Use cache (manually) 📦 # See https://github.com/freckle/stack-cache-action/issues/5
- name: Use cache (manually) 📦 # See https://github.com/freckle/stack-cache-action/issues/5
uses: actions/cache@v2.1.3
# TODO: Cache might be done better, see for inspiration: https://github.com/godu/advent-of-code-2020/blob/46796832f59d185457a8edf8de043a54a451d688/.github/workflows/ci.yml
with:
path: |
path: |
~/.ghc
~/.stack
~/.stack-work
key: ${{ runner.os }}-stack
-
name: Set up MySQL 🧰
- name: Set up Mariadb 🧰
uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: '8.0'
-
name: Setup PHP 🧰
mysql-version: "mariadb-10.6"
- name: Setup PHP 🧰
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
php-version: "8.0"
extensions: mysqli
-
name: Build and test 🏗 🧪
uses: freckle/stack-action@main
- name: Build and test 🏗 🧪
uses: freckle/stack-action@v3
with:
stack-arguments: '--copy-bins --flag ampersand:buildAll'
weeder: false
hlint: false

stack-arguments: "--copy-bins --flag ampersand:buildAll"
- name: Check weeds🌿🌿🌿
uses: freckle/stack-action@v1
with:
weeder: true
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased changes
* [Issue #1267](https://github.com/AmpersandTarski/Ampersand/issues/1267) Automatically add ReleaseNotes to release artefacts
* [Issue #1275](https://github.com/AmpersandTarski/Ampersand/issues/1275) Fix duplicate pattern bug

## v4.6.2 (2 December 2021)

Expand Down
1 change: 1 addition & 0 deletions ampersand.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ extra-source-files:
testing/Travis/testcases/Check/ShouldFail/Issue1063.adl
testing/Travis/testcases/Check/ShouldFail/testinfo.yaml
testing/Travis/testcases/Check/testinfo.yaml
testing/Travis/testcases/FuncSpec/Issue1275.adl
testing/Travis/testcases/FuncSpec/Mandatering/Mandatering.adl
testing/Travis/testcases/FuncSpec/Mandatering/ToevoegenMandaat.adl
testing/Travis/testcases/FuncSpec/testinfo.yaml
Expand Down
4 changes: 2 additions & 2 deletions src/Ampersand/ADL1/PrettyPrinters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Ampersand.ADL1.PrettyPrinters (Pretty (..), prettyPrint) where
import Ampersand.Basics hiding (view, (<$>))
import Ampersand.Core.ParseTree
import Ampersand.Input.ADL1.Lexer (keywords)
import RIO.Char (toUpper)
import RIO.Char (isLetter, toUpper)
import qualified RIO.NonEmpty as NE
import qualified RIO.Set as Set
import qualified RIO.Text as T
Expand Down Expand Up @@ -57,7 +57,7 @@ isId xs =
Nothing -> False
Just (h, _) -> T.all isIdChar xs && isFirstIdChar h && xs `notElem` map T.pack keywords
where
isFirstIdChar x = elem x $ "_" ++ ['a' .. 'z'] ++ ['A' .. 'Z']
isFirstIdChar x = x == '_' || isLetter x
isIdChar x = isFirstIdChar x || elem x ['0' .. '9']

isUpperId :: Text -> Bool
Expand Down
1 change: 0 additions & 1 deletion src/Ampersand/FSpec/SQL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,6 @@ nonSpecialSelectExpr fSpec expr =
traceComment
["case ECpl (EDcV _)"]
emptySet
EDcI ONE -> fatal "EDcI ONE must not be seen at this place."
EDcI c ->
traceComment
["case: ECpl (EDcI c)"]
Expand Down
5 changes: 3 additions & 2 deletions src/Ampersand/FSpec/ShowHS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Ampersand.ADL1
import Ampersand.Basics
import Ampersand.Core.ShowAStruct (AStruct (..)) -- for traceability, we generate comments in the Haskell code.
import Ampersand.FSpec.FSpec
import Ampersand.FSpec.Instances (Instances (instanceList))
import Ampersand.Misc.HasClasses
import Data.Hashable
import RIO.Char (isAlphaNum)
Expand Down Expand Up @@ -353,10 +354,10 @@ instance ShowHS FSpec where
<> T.concat [indent <> " " <> showHSName p <> indent <> " = " <> showHS env (indent <> " ") p | InternalPlug p <- L.sortBy (compare `on` name) (plugInfos fSpec)]
<> "\n"
)
<> ( if null (vpatterns fSpec)
<> ( if null (instanceList fSpec :: [Pattern])
then ""
else
"\n -- *** Patterns (total: " <> (tshow . length . vpatterns) fSpec <> " patterns) ***: "
"\n -- *** Patterns (total: " <> (tshow . length $ (instanceList fSpec :: [Pattern])) <> " patterns) ***: "
<> T.concat [indent <> " " <> showHSName x <> indent <> " = " <> showHS env (indent <> " ") x | x <- vpatterns fSpec]
<> "\n"
)
Expand Down
25 changes: 24 additions & 1 deletion src/Ampersand/FSpec/ToFSpec/ADL2FSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ makeFSpec env context =
allConcepts = fSpecAllConcepts,
cptTType = representationOf contextinfo,
fsisa = L.nub . concatMap genericAndSpecifics . gens $ context,
vpatterns = patterns context,
vpatterns = mergeByName . patterns $ context,
vgens = gens context,
vIndices = identities context,
vviews = viewDefs context,
Expand Down Expand Up @@ -114,6 +114,29 @@ makeFSpec env context =
isSignal = fIsSignal
}
where
mergeByName :: [Pattern] -> [Pattern]
mergeByName [] = []
mergeByName (h : tl) = h' : otherNamedPats
where
(sameNamePats, otherNamedPats) = L.partition (\pat -> name h == name pat) tl
h' = foldr merge h sameNamePats
merge p1 p2 =
A_Pat
{ ptnm = name p1,
ptpos = ptpos p1,
ptend = ptend p1,
ptrls = ptrls p1 <> ptrls p2,
ptgns = ptgns p1 <> ptgns p2,
ptdcs = ptdcs p1 <> ptdcs p2,
ptrrs = ptrrs p1 <> ptrrs p2,
ptcds = ptcds p1 <> ptcds p2,
ptrps = ptrps p1 <> ptrps p2,
ptups = ptups p1 <> ptups p2,
ptids = ptids p1 <> ptids p2,
ptvds = ptvds p1 <> ptvds p2,
ptxps = ptxps p1 <> ptxps p2,
ptenfs = ptenfs p1 <> ptenfs p2
}
fIsSignal :: Rule -> Bool
fIsSignal = not . null . maintainersOf

Expand Down
2 changes: 1 addition & 1 deletion src/Ampersand/Output/ToPandoc/ChapterConceptualAnalysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ chpConceptualAnalysis env lev fSpec =
)
<> purposes2Blocks env (purposesOf fSpec outputLang' fSpec) -- This explains the purpose of this context.
pictures =
map pictOfPat (vpatterns fSpec)
map pictOfPat (instanceList fSpec)
<> map pictOfConcept (Set.elems $ concs fSpec)
<> map pictOfRule (Set.elems $ vrules fSpec)
-----------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions src/Ampersand/Output/ToPandoc/ChapterDiagnosis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ chpDiagnosis env fSpec
outputLang' = outputLang env fSpec
roleomissions :: Blocks
roleomissions
| null (vpatterns fSpec) = mempty
| null (instanceList fSpec :: [Pattern]) = mempty
| (null . fRoleRuls) fSpec && (not . null . vrules) fSpec =
plain
( (emph . str . upCap . name) fSpec
Expand Down Expand Up @@ -380,7 +380,7 @@ chpDiagnosis env fSpec
d `notElem` (bindedRelationsIn . vrules) fSpec
]
pats =
[ pat | pat <- vpatterns fSpec, (not . null) (relsDefdIn pat Set.\\ bindedRelationsIn pat)
[ pat | pat <- instanceList fSpec, (not . null) (relsDefdIn pat Set.\\ bindedRelationsIn pat)
]
pictsWithUnusedRels = [makePicture env fSpec (PTDeclaredInPat pat) | pat <- pats]

Expand Down Expand Up @@ -479,7 +479,7 @@ chpDiagnosis env fSpec
]
)
-- Content rows
( map mkTableRowPat (vpatterns fSpec)
( map mkTableRowPat (instanceList fSpec :: [Pattern])
<> [mkTableRow (l (NL "Gehele context", EN "Entire context")) (Set.filter decusr $ vrels fSpec) (vrules fSpec)]
)
where
Expand Down Expand Up @@ -536,7 +536,7 @@ chpDiagnosis env fSpec
| (rol, rul) <- fRoleRuls fSpec
]
where
multProcs = length (vpatterns fSpec) > 1
multProcs = length (instanceList fSpec :: [Pattern]) > 1

wipReport :: Blocks
wipReport =
Expand Down
6 changes: 3 additions & 3 deletions src/Ampersand/Output/ToPandoc/SharedAmongChapters.hs
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,10 @@ orderingByTheme env fSpec =
dclsOfTheme = fmap dcl2dclCont nrelations,
cptsOfTheme = fmap cpt2cptCont nconcepts
}
| (pat, i, nrules, nrelations, nconcepts) <- L.zip5 (vpatterns fSpec) [0 ..] (NE.init nruless) (NE.init nrelationss) (NE.init nconceptss)
| (pat, i, nrules, nrelations, nconcepts) <- L.zip5 (instanceList fSpec) [0 ..] (NE.init nruless) (NE.init nrelationss) (NE.init nconceptss)
]
<> [ Thm
{ themeNr = length (vpatterns fSpec),
{ themeNr = length (instanceList fSpec :: [Pattern]),
patOfTheme = Nothing,
rulesOfTheme = fmap rul2rulCont (NE.last nruless),
dclsOfTheme = fmap dcl2dclCont (NE.last nrelationss),
Expand All @@ -360,7 +360,7 @@ orderingByTheme env fSpec =
conceptss :: [[AConceptDef]]
relationss :: [Relations]
(ruless, conceptss, relationss) =
L.unzip3 [(ptrls pat, ptcds pat, ptdcs pat) | pat <- vpatterns fSpec]
L.unzip3 [(ptrls pat, ptcds pat, ptdcs pat) | pat <- instanceList fSpec]
numbering :: Int -> [[a]] -> [[Numbered a]]
numbering n (xs : xss) = [Nr i x | (x, i) <- zip xs [n ..]] : numbering (n + length xs) xss
numbering _ _ = []
Expand Down
Loading