Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/trunk' into cp/selection-ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPenner committed Feb 9, 2024
2 parents 8d3016c + 6a6b7b8 commit 0fe5c0c
Show file tree
Hide file tree
Showing 713 changed files with 27,044 additions and 13,610 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ on:
- trunk
tags:
- release/*
workflow_dispatch:


jobs:

Expand All @@ -28,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v37
uses: tj-actions/changed-files@v41
with:
# globs copied from default settings for run-ormolu
files: |
Expand Down Expand Up @@ -229,17 +231,13 @@ jobs:
- name: unison-util-relation tests
run: stack --no-terminal build --fast --test unison-util-relation
- name: round-trip-tests
if: runner.os == 'macOS'
run: |
mkdir -p /private/tmp
touch /private/tmp/roundtrip.u
touch /private/tmp/rewrite-tmp.u
stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
git add unison-src/transcripts-round-trip/main.output.md
git add unison-src/transcripts-round-trip/main.output.md
# Fail if any transcripts cause git diffs.
git diff --cached --ignore-cr-at-eol --exit-code
stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md
git add unison-src/transcripts-manual/rewrites.output.md
git add unison-src/transcripts-manual/rewrites.output.md
# Fail if any transcripts cause git diffs.
git diff --cached --ignore-cr-at-eol --exit-code
- name: transcripts
Expand Down Expand Up @@ -314,6 +312,9 @@ jobs:
exit 1
fi
- name: verify stack ghci startup
if: runner.os == 'macOS'
run: echo | stack ghci
- name: check final stackage cache size
run: |
echo global .stack
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/haddocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ jobs:
# Erase any stale files
cd "$GITHUB_WORKSPACE"/haddocks
rm -rf ./*
git checkout --orphan fresh-haddocks-branch
cp -r "${docs_root}"/* "$GITHUB_WORKSPACE"/haddocks
if [[ -z "$(git status --porcelain)" ]]; then
echo No changes.
else
git add .
git commit -m "Regenerated haddocks based on ${GITHUB_SHA}"
git push
fi
git add .
git commit -m "Regenerated haddocks based on ${GITHUB_SHA}"
# Push the branch with only a single commit over the remote
git push --force origin fresh-haddocks-branch:haddocks
3 changes: 2 additions & 1 deletion .github/workflows/nix-dev-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
matrix:
os:
- ubuntu-20.04
- macOS-12
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
Expand All @@ -32,5 +33,5 @@ jobs:
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'
run: nix -L build --accept-flake-config --no-link --keep-going '.#build-tools'

13 changes: 11 additions & 2 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,16 @@ jobs:
echo "$PWD/stack-"* >> $GITHUB_PATH
- name: build
run: stack --no-terminal build --flag unison-parser-typechecker:optimized
# Run up to 5 times in a row before giving up.
# Builds sometimes fail due to a race condition on the Windows
# file-system API that stack runs into. Since any successful packages are
# cached within a single build, it should get further along on each re-start
# and should hopefully finish.
run: |
tries=5
for (( i = 0; i < $tries; i++ )); do
stack --no-terminal build --flag unison-parser-typechecker:optimized && break;
done
- name: fetch latest codebase-ui and package with ucm
env:
Expand Down Expand Up @@ -153,7 +162,7 @@ jobs:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
automatic_release_tag: "trunk-build"
prerelease: true
title: "Development Build"
files: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
workflow_dispatch:
inputs:
version:
description: 'Release Version (E.g. M4 or M4a)'
description: 'Release Version (E.g. M4 or M4a or 0.4.1)'
required: true
type: string
target:
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/update-transcripts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: update-transcripts

on:
workflow_dispatch:

jobs:
update_transcripts:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
os:
- macOS-12
steps:
- uses: actions/checkout@v4
- id: stackage-resolver
name: record stackage resolver
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
# looks for `resolver: nightly-yyyy-mm-dd` or `resolver: lts-xx.yy` in `stack.yaml` and splits it into
# `nightly` or `lts-xx`. the whole resolver string is put into resolver_long as a backup cache key
# ${{ steps.stackage-resolver.outputs.resolver_short }}
# ${{ steps.stackage-resolver.outputs.resolver_long }}
run: |
grep resolver stack.yaml | awk '{ x="resolver_short="; if (split($2,a,"-") > 2) print x a[1]; else {split($2,b,"."); print x b[1]}}' >> "$GITHUB_OUTPUT"
grep resolver stack.yaml | awk '{print "resolver_long="$2}' >> "$GITHUB_OUTPUT"
# Cache ~/.stack, keyed by the contents of 'stack.yaml'.
- uses: actions/cache@v3
name: cache ~/.stack (unix)
if: runner.os != 'Windows'
with:
path: ~/.stack
key: stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}}
# Fall-back to use the most recent cache for the stack.yaml, or failing that the OS
restore-keys: |
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-
stack-1_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}.
stack-1_${{matrix.os}}-
# Cache each local package's ~/.stack-work for fast incremental builds in CI.
- uses: actions/cache@v3
name: cache .stack-work
with:
path: |
**/.stack-work
# Main cache key: commit hash. This should always result in a cache miss...
# So when loading a cache we'll always fall back to the restore-keys,
# which should load the most recent cache via a prefix search on the most
# recent branch cache.
# Then it will save a new cache at this commit sha, which should be used by
# the next build on this branch.
key: stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-${{hashFiles('**/stack.yaml')}}-${{github.sha}}
restore-keys: |
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-${{hashFiles('**/stack.yaml')}}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_long }}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}-
stack-work-4_${{matrix.os}}-${{ steps.stackage-resolver.outputs.resolver_short }}.
stack-work-4_${{matrix.os}}-
# Install stack by downloading the binary from GitHub.
# The installation process differs by OS.
- name: install stack (Linux)
if: runner.os == 'Linux'
working-directory: ${{ runner.temp }}
run: |
mkdir stack && cd stack
curl -L https://github.com/commercialhaskell/stack/releases/download/v2.9.1/stack-2.9.1-linux-x86_64.tar.gz | tar -xz
echo "$PWD/stack-"* >> $GITHUB_PATH
# One of the transcripts fails if the user's git name hasn't been set.
- name: set git user info
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "[email protected]"
- name: build
run: stack --no-terminal build --fast --no-run-tests --test
- name: round-trip-tests
run: |
stack --no-terminal exec unison transcript unison-src/transcripts-round-trip/main.md
stack --no-terminal exec unison transcript unison-src/transcripts-manual/rewrites.md
- name: transcripts
run: stack --no-terminal exec transcripts
- name: save transcript changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: rerun transcripts (reminder to rerun CI!)
4 changes: 4 additions & 0 deletions CONTRIBUTORS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,18 @@ The format for this list: name, GitHub handle
* Nicole Prindle (@nprindle)
* Harald Gliebe (@hagl)
* Phil de Joux (@philderbeast)
* Daroc Alden (@setupminimal)
* Travis Staton (@tstat)
* Dan Freeman (@dfreeman)
* Emil Hotkowski (@emilhotkowski)
* Jesse Looney (@jesselooney)
* Vlad Posmangiu Luchian (@cstml)
* Andrii Uvarov (@unorsk)
* Fabio Labella (@SystemFw)
* Alexis King (@lexi-lambda)
* Mario Bašić (@mabasic)
* Chris Krycho (@chriskrycho)
* Hatim Khambati (@hatimkhambati26)
* Kyle Goetz (@kylegoetz)
* Ethan Morgan (@sixfourtwelve)
* Johan Winther (@JohanWinther)
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM debian:stable

RUN adduser --home /unison --disabled-password unison

RUN apt-get update && \
apt-get install -y git libncurses5 less locales fzf && \
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8


COPY tmp/ucm/ucm /usr/local/bin/ucm
COPY tmp/ucm/ui /usr/local/share/ucm

ENV UCM_WEB_UI=/usr/local/share/ucm
ENV UCM_PORT=8080
ENV UCM_TOKEN=pub

RUN chmod 555 /usr/local/bin/ucm

EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/ucm"]
CMD ["--codebase","/unison"]
3 changes: 3 additions & 0 deletions codebase2/codebase-sqlite-hashing-v2/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- bytes
- bytestring
- containers
- generic-lens
- lens
- text
- unison-codebase
Expand All @@ -19,6 +20,7 @@ dependencies:
- unison-hashing-v2
- unison-prelude
- unison-sqlite
- unison-syntax
- unison-util-base32hex
- unison-util-term
- vector
Expand Down Expand Up @@ -49,6 +51,7 @@ default-extensions:
- LambdaCase
- MultiParamTypeClasses
- NamedFieldPuns
- OverloadedLabels
- OverloadedStrings
- PatternSynonyms
- RecordWildCards
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
module U.Codebase.Branch.Hashing (hashBranch) where
module U.Codebase.Branch.Hashing
( hashBranch,
hashBranchV3,
)
where

import U.Codebase.Branch (Branch)
import U.Codebase.BranchV3 (BranchV3)
import U.Codebase.HashTags
import Unison.Hashing.V2 qualified as Hashing
import Unison.Hashing.V2.Convert2 (v2ToH2Branch)
import Unison.Hashing.V2.Convert2 (convertBranchV3, v2ToH2Branch)

hashBranch :: forall m. Monad m => Branch m -> m BranchHash
hashBranch branch =
BranchHash . Hashing.contentHash <$> v2ToH2Branch branch

-- | Hash a V3 branch.
hashBranchV3 :: BranchV3 m -> BranchHash
hashBranchV3 =
BranchHash . Hashing.contentHash . convertBranchV3
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module U.Codebase.Decl.Hashing where

import Control.Lens
import Data.Foldable qualified as Foldable
import Data.Map qualified as Map
import U.Codebase.Decl qualified as C
import U.Codebase.Decl qualified as C.Decl
import U.Codebase.HashTags
import U.Codebase.Reference qualified as Reference
import U.Codebase.Sqlite.Decl.Format qualified as DeclFormat
import U.Codebase.Sqlite.HashHandle (HashMismatch (..))
import U.Codebase.Sqlite.HashHandle qualified as HH
import U.Codebase.Sqlite.LocalIds qualified as LocalIds
import U.Codebase.Sqlite.Queries qualified as Q
import U.Codebase.Sqlite.Symbol qualified as S
import U.Codebase.Sqlite.Symbol qualified as Sqlite
import Unison.Hash32
import Unison.Hash32 qualified as Hash32
import Unison.Hashing.V2 qualified as H2
import Unison.Hashing.V2.Convert2 qualified as H2
import Unison.Prelude
import Unison.Symbol qualified as Unison
import Unison.Syntax.Name qualified as Name
import Unison.Var qualified as Var

verifyDeclFormatHash :: ComponentHash -> DeclFormat.HashDeclFormat -> Maybe HH.DeclHashingError
verifyDeclFormatHash (ComponentHash hash) (DeclFormat.Decl (DeclFormat.LocallyIndexedComponent elements)) =
Foldable.toList elements
& fmap s2cDecl
& Reference.component hash
& fmap (\(decl, refId) -> (refId, (C.Decl.vmap symbol2to1 decl, ())))
& Map.fromList
& C.Decl.unhashComponent hash Var.unnamedRef
& Map.toList
& fmap (\(_refId, (v, decl, ())) -> (v, either H2.toDataDecl id $ H2.v2ToH2Decl decl))
& Map.fromList
& H2.hashDecls Name.unsafeFromVar
& \case
Left _err -> Just HH.DeclHashResolutionFailure
Right m ->
m
& altMap \(_, H2.ReferenceId hash' _, _) ->
if hash == hash'
then Nothing
else Just (HH.DeclHashMismatch $ HashMismatch hash hash')
where
symbol2to1 :: S.Symbol -> Unison.Symbol
symbol2to1 (S.Symbol i t) = Unison.Symbol i (Var.User t)

s2cDecl :: (LocalIds.LocalIds' Text Hash32, DeclFormat.Decl Sqlite.Symbol) -> C.Decl Sqlite.Symbol
s2cDecl (ids, decl) =
let Identity (substText, substHash) = Q.localIdsToLookups Identity pure (bimap id Hash32.toHash ids)
refmap = (bimap substText (fmap substHash))
in Q.x2cDecl refmap decl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import Data.Function ((&))
import Data.Set qualified as Set
import U.Codebase.Branch.Hashing qualified as H2
import U.Codebase.Causal.Hashing qualified as H2
import U.Codebase.HashTags (BranchHash (..))
import U.Codebase.Decl.Hashing qualified as H2
import U.Codebase.HashTags (BranchHash (..), PatchHash (..))
import U.Codebase.Sqlite.Branch.Format qualified as BranchFormat
import U.Codebase.Sqlite.HashHandle
import U.Codebase.Sqlite.Patch.Format qualified as PatchFormat
import U.Codebase.Term.Hashing as H2
import U.Util.Type (removeAllEffectVars)
import Unison.Hashing.V2 qualified as H2
import Unison.Hashing.V2.Convert2 (h2ToV2Reference, hashBranchFormatToH2Branch, v2ToH2Type, v2ToH2TypeD)
import Unison.Hashing.V2.Convert2 (h2ToV2Reference, hashBranchFormatToH2Branch, hashPatchFormatToH2Patch, v2ToH2Type, v2ToH2TypeD)

v2HashHandle :: HashHandle
v2HashHandle =
Expand All @@ -22,10 +25,21 @@ v2HashHandle =
toReferenceDecl = \h -> h2ToV2Reference . H2.typeToReference . v2ToH2TypeD h . removeAllEffectVars,
toReferenceDeclMentions = \h -> Set.map h2ToV2Reference . H2.typeToReferenceMentions . v2ToH2TypeD h . removeAllEffectVars,
hashBranch = H2.hashBranch,
hashBranchV3 = H2.hashBranchV3,
hashCausal = H2.hashCausal,
hashBranchFormatFull = \localIds localBranch ->
BranchFormat.localToHashBranch localIds localBranch
& hashBranchFormatToH2Branch
& H2.contentHash
& BranchHash
hashBranchFormatFull,
hashPatchFormatFull,
verifyTermFormatHash = H2.verifyTermFormatHash,
verifyDeclFormatHash = H2.verifyDeclFormatHash
}
where
hashBranchFormatFull localIds localBranch =
BranchFormat.localToHashBranch localIds localBranch
& hashBranchFormatToH2Branch
& H2.contentHash
& BranchHash
hashPatchFormatFull localIds localPatch =
PatchFormat.localPatchToHashPatch localIds localPatch
& hashPatchFormatToH2Patch
& H2.contentHash
& PatchHash
Loading

0 comments on commit 0fe5c0c

Please sign in to comment.