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

Go list to generate build graph #5

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions .github/workflows/testthatstuff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
working-directory: ./examplerepo
run: ../go-deps -m github.com/grpc-ecosystem/grpc-gateway -v v1.16.0 && ./pleasew build //third_party/...

- name: Test github.com/jamesjarvis/go-deps
- name: Test github.com/tatskaari/go-deps
working-directory: ./examplerepo
run: ../go-deps -m github.com/jamesjarvis/go-deps && ./pleasew build //third_party/...
run: ../go-deps -m github.com/tatskaari/go-deps && ./pleasew build //third_party/...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.idea
tmp/
plz-out/
.idea

# Entries below this point are managed by Please (DO NOT EDIT)
plz-out
Expand Down
14 changes: 3 additions & 11 deletions .plzconfig
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
; Please config file
; Leaving this file as is is enough to use plz to build your project.
; Please will stay on whatever version you currently have until you run
; 'plz update', when it will download the latest available version.
;
; Or you can uncomment the following to pin everyone to a particular version;
; when you change it all users will automatically get updated.
; [please]
; version = 16.5.1
[please]
version = 16.8.0

[go]
gotool = //third_party/go:toolchain|go
;goroot - ...
importpath = github.com/jamesjarvis/go-deps
importpath = github.com/tatskaari/go-deps

[parse]
; We ignore the examplerepo as it is used for testing.
Expand Down
6 changes: 3 additions & 3 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ go_binary(
name = "go-deps",
srcs = ["main.go"],
deps = [
"//host",
"//module",
"//third_party/go:cli.v2",
"//resolve",
"//rules",
"//third_party/go/github.com/urfave/cli/v2",
],
)
4 changes: 0 additions & 4 deletions examplerepo/.plzconfig
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
; Please config file

[please]
version = 16.4.1
19 changes: 0 additions & 19 deletions examplerepo/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +0,0 @@
# Example Repo

This repo contains the output of running:

```bash
go run ../main.go -m github.com/grpc-ecosystem/grpc-gateway -v v1.16.0
```

This was arbitrarily chosen as it's a kinda hard module to download (as there are many dependencies of dependencies and some are outdated).

As of 7/8/21 This does not generate an output that builds with `plz build //third_party/go/...` without manual intervention.

Example Tests:

- ✅ `go run ../main.go -m github.com/stretchr/testify -v v1.6.1`
- ❌ `go run ../main.go -m github.com/grpc-ecosystem/grpc-gateway -v v1.16.0`
- This is because some dependencies do not actually contain go.mod files at the requested version, so their builds fail.
- ❌ `go run ../main.go -m github.com/jamesjarvis/go-deps`
- Ironically this fails due to old tags of dependencies not containing go.mod or failing to include all required modules.
71 changes: 0 additions & 71 deletions examplerepo/pleasew
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,71 +0,0 @@
#!/usr/bin/env bash
set -u

RED="\x1B[31m"
GREEN="\x1B[32m"
YELLOW="\x1B[33m"
RESET="\x1B[0m"

DEFAULT_URL_BASE="https://get.please.build"
# We might already have it downloaded...
LOCATION=`grep -i "^location" .plzconfig 2>/dev/null | cut -d '=' -f 2 | tr -d ' '`
if [ -z "$LOCATION" ]; then
if [ -z "$HOME" ]; then
echo -e >&2 "${RED}\$HOME not set, not sure where to look for Please.${RESET}"
exit 1
fi
LOCATION="${HOME}/.please"
else
# It can contain a literal ~, need to explicitly handle that.
LOCATION="${LOCATION/\~/$HOME}"
fi
# If this exists at any version, let it handle any update.
TARGET="${LOCATION}/please"
if [ -f "$TARGET" ]; then
exec "$TARGET" ${PLZ_ARGS:-} "$@"
fi

URL_BASE="`grep -i "^downloadlocation" .plzconfig | cut -d '=' -f 2 | tr -d ' '`"
if [ -z "$URL_BASE" ]; then
URL_BASE=$DEFAULT_URL_BASE
fi
URL_BASE="${URL_BASE%/}"

VERSION="`grep -i "^version[^a-z]" .plzconfig`"
VERSION="${VERSION#*=}" # Strip until after first =
VERSION="${VERSION/ /}" # Remove all spaces
VERSION="${VERSION#>=}" # Strip any initial >=
if [ -z "$VERSION" ]; then
echo -e >&2 "${YELLOW}Can't determine version, will use latest.${RESET}"
VERSION=`curl -fsSL ${URL_BASE}/latest_version`
fi

# Find the os / arch to download. You can do this quite nicely with go env
# but we use this script on machines that don't necessarily have Go itself.
OS=`uname`
if [ "$OS" = "Linux" ]; then
GOOS="linux"
elif [ "$OS" = "Darwin" ]; then
GOOS="darwin"
else
echo -e >&2 "${RED}Unknown operating system $OS${RESET}"
exit 1
fi
# Don't have any builds other than amd64 at the moment.
ARCH="amd64"

PLEASE_URL="${URL_BASE}/${GOOS}_${ARCH}/${VERSION}/please_${VERSION}.tar.xz"
DIR="${LOCATION}/${VERSION}"
# Potentially we could reuse this but it's easier not to really.
if [ ! -d "$DIR" ]; then
rm -rf "$DIR"
fi
echo -e >&2 "${GREEN}Downloading Please ${VERSION} to ${DIR}...${RESET}"
mkdir -p "$DIR"
curl -fsSL "${PLEASE_URL}" | tar -xJpf- --strip-components=1 -C "$DIR"
# Link it all back up a dir
for x in `ls "$DIR"`; do
ln -sf "${DIR}/${x}" "$LOCATION"
done
echo -e >&2 "${GREEN}Should be good to go now, running plz...${RESET}"
exec "$TARGET" ${PLZ_ARGS:-} "$@"
16 changes: 12 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
module github.com/jamesjarvis/go-deps
module github.com/tatskaari/go-deps

go 1.16

require (
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/bazelbuild/buildtools v0.0.0-20210824143317-0a897f9af678
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/google/go-licenses v0.0.0-20210816172045-3099c18c36e1
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/mod v0.4.2
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/mod v0.4.0 // indirect
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
golang.org/x/tools v0.0.0-20210106214847-113979e3529a
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
Loading