From 6e05935fb8b7b0c4fc24c73d63e9c71a91ab209b Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Thu, 3 Aug 2023 10:43:49 -0400 Subject: [PATCH 1/8] add "all" package to flake --- flake.nix | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/flake.nix b/flake.nix index 16e0d2acf..0599a931b 100644 --- a/flake.nix +++ b/flake.nix @@ -163,5 +163,16 @@ defaultPackage = flake.packages."unison-cli:exe:unison"; inherit (pkgs) unison-project; inherit devShells localPackageNames; + packages = flake.packages // { + all = pkgs.symlinkJoin { + name = "all-packages"; + paths = + let + all-other-packages = builtins.attrValues (builtins.removeAttrs self.packages."${system}" [ "all" ]); + devshell-inputs = builtins.concatMap (devShell: devShell.buildInputs ++ devShell.nativeBuildInputs) [ devShells.only-tools ]; + in + all-other-packages ++ devshell-inputs; + }; + }; }); } From 4197042066811b6c0cc360a9e705c6b70fcaa8f1 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Thu, 3 Aug 2023 10:44:19 -0400 Subject: [PATCH 2/8] add workflow that populates cache --- .github/workflows/nix-dev-cache.yaml | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/nix-dev-cache.yaml diff --git a/.github/workflows/nix-dev-cache.yaml b/.github/workflows/nix-dev-cache.yaml new file mode 100644 index 000000000..13ab02ae0 --- /dev/null +++ b/.github/workflows/nix-dev-cache.yaml @@ -0,0 +1,33 @@ +name: Nix development cache + +on: + # Build on every pull request (and new PR commit) + pull_request: + # Build on new pushes to trunk (E.g. Merge commits) + # Without the branch filter, each commit on a branch with a PR is triggered twice. + # See: https://github.community/t/how-to-trigger-an-action-on-push-or-pull-request-but-not-both/16662 + push: + branches: + - trunk + +jobs: + nix: + name: ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + # Run each build to completion, regardless of if any have failed + fail-fast: false + matrix: + os: + - ubuntu-20.04 + - macOS-12 + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v22 + - uses: cachix/cachix-action@v12 + with: + name: unison + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: build all packages and development shells + run: nix -L build --accept-flake-config --no-link --keep-going '.#all' + From cd048f7bdddd212ab3cb7a27fe932ebeecdd1ec6 Mon Sep 17 00:00:00 2001 From: Kyle Goetz Date: Sun, 6 Aug 2023 15:41:15 -0500 Subject: [PATCH 3/8] fixes #4233 - term declarations should not allow hashes in term names --- CONTRIBUTORS.markdown | 1 + parser-typechecker/src/Unison/Syntax/TermParser.hs | 6 +++--- unison-syntax/src/Unison/Syntax/Parser.hs | 13 +++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS.markdown b/CONTRIBUTORS.markdown index 2aba044b9..52881ca1e 100644 --- a/CONTRIBUTORS.markdown +++ b/CONTRIBUTORS.markdown @@ -76,3 +76,4 @@ The format for this list: name, GitHub handle * Mario Bašić (@mabasic) * Chris Krycho (@chriskrycho) * Hatim Khambati (@hatimkhambati26) +* Kyle Goetz (@kylegoetz) diff --git a/parser-typechecker/src/Unison/Syntax/TermParser.hs b/parser-typechecker/src/Unison/Syntax/TermParser.hs index c52cadf6b..0784dba5c 100644 --- a/parser-typechecker/src/Unison/Syntax/TermParser.hs +++ b/parser-typechecker/src/Unison/Syntax/TermParser.hs @@ -985,7 +985,7 @@ infixAppOrBooleanOp = chainl1 term4 (or <|> and <|> infixApp) typedecl :: (Monad m, Var v) => P v m (L.Token v, Type v Ann) typedecl = (,) - <$> P.try (prefixDefinitionName <* reserved ":") + <$> P.try (prefixTermName <* reserved ":") <*> TypeParser.valueType <* semi @@ -1053,8 +1053,8 @@ binding = label "binding" do arg2 <- prefixDefinitionName pure (ann arg1, op, [arg1, arg2]) let prefixLhs = do - v <- prefixDefinitionName - vs <- many prefixDefinitionName + v <- prefixTermName + vs <- many prefixTermName pure (ann v, v, vs) let lhs :: P v m (Ann, L.Token v, [L.Token v]) lhs = infixLhs <|> prefixLhs diff --git a/unison-syntax/src/Unison/Syntax/Parser.hs b/unison-syntax/src/Unison/Syntax/Parser.hs index 1bb641107..a9378d4ff 100644 --- a/unison-syntax/src/Unison/Syntax/Parser.hs +++ b/unison-syntax/src/Unison/Syntax/Parser.hs @@ -297,6 +297,19 @@ prefixDefinitionName :: (Var v) => P v m (L.Token v) prefixDefinitionName = wordyDefinitionName <|> parenthesize symbolyDefinitionName +-- Parse a prefix identifier e.g. Foo or (+), rejecting any hash +-- This is useful for term declarations, where type signatures and term names should not have hashes. +prefixTermName :: (Var v) => P v (L.Token v) +prefixTermName = wordyTermName <|> parenthesize symbolyTermName + where + wordyTermName = queryToken $ \case + L.WordyId s Nothing -> Just $ Var.nameds s + L.Blank s -> Just $ Var.nameds ("_" <> s) + _ -> Nothing + symbolyTermName = queryToken $ \case + L.SymbolyId s Nothing -> Just $ Var.nameds s + _ -> Nothing + -- Parse a wordy identifier e.g. Foo, discarding any hash wordyDefinitionName :: (Var v) => P v m (L.Token v) wordyDefinitionName = queryToken $ \case From e3e008857ee9afc82a25a72447aeca07522b67f4 Mon Sep 17 00:00:00 2001 From: Kyle Goetz Date: Sun, 6 Aug 2023 14:58:21 -0500 Subject: [PATCH 4/8] added transcript test to verify using a hash in term declaration is an error --- unison-src/transcripts/no-hash-in-term-declaration.md | 8 ++++++++ .../transcripts/no-hash-in-term-declaration.output.md | 4 ++++ 2 files changed, 12 insertions(+) create mode 100644 unison-src/transcripts/no-hash-in-term-declaration.md create mode 100644 unison-src/transcripts/no-hash-in-term-declaration.output.md diff --git a/unison-src/transcripts/no-hash-in-term-declaration.md b/unison-src/transcripts/no-hash-in-term-declaration.md new file mode 100644 index 000000000..ac43b449a --- /dev/null +++ b/unison-src/transcripts/no-hash-in-term-declaration.md @@ -0,0 +1,8 @@ +# No Hashes in Term Declarations + +There should not be hashes in the names used in term declarations, either in the type signature or the type definition. + +```unison:hide:all:error +x##Nat : Int -> Int -> Boolean +x##Nat = 5 +``` \ No newline at end of file diff --git a/unison-src/transcripts/no-hash-in-term-declaration.output.md b/unison-src/transcripts/no-hash-in-term-declaration.output.md new file mode 100644 index 000000000..aa3dc9d9f --- /dev/null +++ b/unison-src/transcripts/no-hash-in-term-declaration.output.md @@ -0,0 +1,4 @@ +# No Hashes in Term Declarations + +There should not be hashes in the names used in term declarations, either in the type signature or the type definition. + From 5258b6c8a33bb759c5b07b241faf5e25086cb49e Mon Sep 17 00:00:00 2001 From: Kyle Goetz Date: Sun, 6 Aug 2023 23:37:20 -0500 Subject: [PATCH 5/8] fixup --- unison-syntax/src/Unison/Syntax/Parser.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unison-syntax/src/Unison/Syntax/Parser.hs b/unison-syntax/src/Unison/Syntax/Parser.hs index a9378d4ff..af1e504c0 100644 --- a/unison-syntax/src/Unison/Syntax/Parser.hs +++ b/unison-syntax/src/Unison/Syntax/Parser.hs @@ -31,6 +31,7 @@ module Unison.Syntax.Parser peekAny, positionalVar, prefixDefinitionName, + prefixTermName, queryToken, reserved, root, @@ -299,7 +300,7 @@ prefixDefinitionName = -- Parse a prefix identifier e.g. Foo or (+), rejecting any hash -- This is useful for term declarations, where type signatures and term names should not have hashes. -prefixTermName :: (Var v) => P v (L.Token v) +prefixTermName :: (Var v) => P v m (L.Token v) prefixTermName = wordyTermName <|> parenthesize symbolyTermName where wordyTermName = queryToken $ \case From 2e456e2ad0c70391d40e73bbcf94f8c153b4f8da Mon Sep 17 00:00:00 2001 From: Arya Irani <538571+aryairani@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:53:52 -0400 Subject: [PATCH 6/8] remove cache.iog.io Some of the packages had invalid signatures for darwin --- flake.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 16e0d2acf..06f5967bf 100644 --- a/flake.nix +++ b/flake.nix @@ -1,9 +1,8 @@ { description = "Unison"; nixConfig = { - extra-substituters = [ "https://cache.iog.io" "https://unison.cachix.org" ]; + extra-substituters = [ "https://unison.cachix.org" ]; extra-trusted-public-keys = [ - "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "unison.cachix.org-1:i1DUFkisRPVOyLp/vblDsbsObmyCviq/zs6eRuzth3k=" ]; }; From 4b4b0c9cda00a09f0d335cb16001c62e65778e8e Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 8 Aug 2023 09:10:48 -0700 Subject: [PATCH 7/8] Remove Share paths from release flow --- .github/workflows/release.yaml | 17 +++-------------- scripts/make-release.sh | 10 ++++------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5625dec3f..6ca80242d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -11,10 +11,6 @@ on: description: 'Release Version (E.g. M4 or M4a)' required: true type: string - share_base_path: - description: 'Path to base version that UCM should pull by default (E.g. `unison.public.base.releases.M4`)' - required: true - type: string target: description: 'Ref to use for this release, defaults to trunk' required: true @@ -61,8 +57,6 @@ jobs: name: "build_linux" runs-on: ubuntu-20.04 - env: - UNISON_BASE_PATH: "${{inputs.share_base_path}}" steps: - uses: actions/checkout@v2 with: @@ -109,7 +103,7 @@ jobs: - name: build run: | - # unison-cli checks env vars for which base version to automatically pull, + # unison-cli embeds version numbers using TH # so it needs to be forced to rebuild to ensure those are updated. stack clean unison-cli stack --no-terminal build --flag unison-parser-typechecker:optimized @@ -133,8 +127,6 @@ jobs: build_macos: name: "build_macos" runs-on: macos-12 - env: - UNISON_BASE_PATH: "${{inputs.share_base_path}}" steps: - uses: actions/checkout@v2 with: @@ -184,7 +176,7 @@ jobs: - name: build run: | - # unison-cli checks env vars for which base version to automatically pull, + # unison-cli embeds version numbers using TH # so it needs to be forced to rebuild to ensure those are updated. stack clean unison-cli stack --no-terminal build --flag unison-parser-typechecker:optimized @@ -208,9 +200,6 @@ jobs: build_windows: name: "build_windows" runs-on: windows-2019 - env: - UNISON_BASE_PATH: "${{inputs.share_base_path}}" - steps: - uses: actions/checkout@v2 with: @@ -257,7 +246,7 @@ jobs: - name: build run: | - # unison-cli checks env vars for which base version to automatically pull, + # unison-cli embeds version numbers using TH # so it needs to be forced to rebuild to ensure those are updated. stack clean unison-cli diff --git a/scripts/make-release.sh b/scripts/make-release.sh index 1ff1da7fd..0bed03c9a 100755 --- a/scripts/make-release.sh +++ b/scripts/make-release.sh @@ -9,16 +9,15 @@ fi usage() { echo "NOTE: must be run from the root of the project." - echo "Usage: $0 VERSION SHARE_BASE_PATH [TARGET]" + echo "Usage: $0 VERSION [TARGET]" echo "VERSION: The version you're releasing, e.g. M4a" - echo "SHARE_BASE_PATH: Which base version to pull from share, e.g. 'unison.public.base.releases.M4'" echo "TARGET: The revision to make the release from, defaults to 'trunk'" echo "" echo "E.g." echo "$0 M4a" } -if [[ -z "$1" || -z "$2" ]] ; then +if [[ -z "$1" ]] ; then usage exit 1 fi @@ -36,8 +35,7 @@ fi version="${1}" prev_version=$(./scripts/previous-tag.sh "$version") -share_base_path=${2} -target=${3:-trunk} +target=${2:-trunk} tag="release/${version}" echo "Creating release in unison-local-ui..." @@ -46,7 +44,7 @@ gh release create "release/${version}" --repo unisonweb/unison-local-ui --target echo "Kicking off release workflow in unisonweb/unison" git tag "${tag}" "${target}" git push origin "${tag}" -gh workflow run release --repo unisonweb/unison --field "version=${version}" --field "share_base_path=${share_base_path}" +gh workflow run release --repo unisonweb/unison --field "version=${version}" echo "Kicking off Homebrew update task" gh workflow run release --repo unisonweb/homebrew-unison --field "version=${version}" From b0a8ac5e4e03e7c728379ea1a6c0b95a4cf795ac Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 8 Aug 2023 14:06:34 -0700 Subject: [PATCH 8/8] Add namespace, term, type autocomplete --- unison-cli/src/Unison/CommandLine/InputPatterns.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/unison-cli/src/Unison/CommandLine/InputPatterns.hs b/unison-cli/src/Unison/CommandLine/InputPatterns.hs index b6605d78b..bd9ceecaf 100644 --- a/unison-cli/src/Unison/CommandLine/InputPatterns.hs +++ b/unison-cli/src/Unison/CommandLine/InputPatterns.hs @@ -6,6 +6,7 @@ module Unison.CommandLine.InputPatterns where import Control.Lens (preview, (^.)) import Control.Lens.Cons qualified as Cons import Data.List (intercalate) +import Data.List.Extra qualified as List import Data.List.NonEmpty qualified as NE import Data.Map qualified as Map import Data.Maybe (fromJust) @@ -452,7 +453,7 @@ ui = { patternName = "ui", aliases = [], visibility = I.Visible, - argTypes = [], + argTypes = [(Optional, namespaceOrDefinitionArg)], help = P.wrap "`ui` opens the Local UI in the default browser.", parse = \case [] -> pure $ Input.UiI Path.relativeEmpty' @@ -2963,6 +2964,17 @@ namespaceArg = globTargets = Set.fromList [Globbing.Namespace] } +namespaceOrDefinitionArg :: ArgumentType +namespaceOrDefinitionArg = + ArgumentType + { typeName = "term, type, or namespace", + suggestions = \q cb _http p -> Codebase.runTransaction cb do + namespaces <- prefixCompleteNamespace q p + termsTypes <- prefixCompleteTermOrType q p + pure (List.nubOrd $ namespaces <> termsTypes), + globTargets = Set.fromList [Globbing.Namespace, Globbing.Term, Globbing.Type] + } + -- | Names of child branches of the branch, only gives options for one 'layer' deeper at a time. childNamespaceNames :: Branch.Branch0 m -> [Text] childNamespaceNames b = NameSegment.toText <$> Map.keys (Branch.nonEmptyChildren b)