Skip to content

Commit

Permalink
migrate go version to 1.17 (#203)
Browse files Browse the repository at this point in the history
* migrate go version to 1.17

* update contributing
  • Loading branch information
tsmethurst authored Sep 10, 2021
1 parent e681aac commit f2e5bed
Show file tree
Hide file tree
Showing 282 changed files with 11,849 additions and 12,586 deletions.
9 changes: 4 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ steps:
# We use golangci-lint for linting.
# See: https://golangci-lint.run/
- name: lint
image: golangci/golangci-lint:v1.41.1
image: golangci/golangci-lint:v1.42.1
volumes:
- name: go-build-cache
path: /root/.cache/go-build
Expand All @@ -27,17 +27,16 @@ steps:
- pull_request

- name: test
image: golang:1.16.4
image: golang:1.17.1
volumes:
- name: go-build-cache
path: /root/.cache/go-build
environment:
GTS_DB_ADDRESS: postgres
commands:
# `-count 1` => run all tests at least once
# `-p 1` => run maximum one test at a time
# `./...` => run all tests
- go test -count 1 -p 1 ./...
- go test -p 1 ./...
when:
event:
include:
Expand Down Expand Up @@ -86,6 +85,6 @@ trigger:

---
kind: signature
hmac: 7fa6fa70be0a5c436ecb2f02f4b74bd1be5e90817e2d95a16898e3d29cbadf80
hmac: 268d484fd9c5d14834a3e2a1e39cfe605c3898d601d2969dba5c2e11c1ea2f3b

...
54 changes: 17 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Hey! Welcome to the CONTRIBUTING.md for GoToSocial :) Thanks for taking a look,

This document will expand as the project expands, so for now this is basically a stub.

Contributions are welcome at this point, since the API is fairly stable now and the structure is at least vaguely coherent.
Contributions are welcome at this point, since the API is fairly stable now and the structure is somewhat coherent.

Check the [issues](https://github.com/superseriousbusiness/gotosocial/issues) to see if there's anything you fancy jumping in on.

Expand All @@ -20,11 +20,11 @@ In lieu of a fuller code of conduct, here are a few ground rules.

1. We *DO NOT ACCEPT* PRs from right-wingers, Nazis, transphobes, homophobes, racists, harassers, abusers, white-supremacists, misogynists, tech-bros of questionable ethics. If that's you, politely fuck off somewhere else.
2. Any PR that moves GoToSocial in the direction of surveillance capitalism or other bad fediverse behavior will be rejected.
3. Don't spam the chat too hard.
3. Don't spam the general chat too hard.

## Setting up your development environment

To get started, you first need to have Go installed. GTS was developed with Go 1.16.4, so you should take that too. See [here](https://golang.org/doc/install).
To get started, you first need to have Go installed. GtS is currently using Go 1.17, so you should take that too. See [here](https://golang.org/doc/install).

Once you've got go installed, clone this repository into your Go path. Normally, this should be `~/go/src/github.com/superseriousbusiness/gotosocial`.

Expand All @@ -48,55 +48,35 @@ In case this post disappears, here are the steps (slightly modified):

>
> Pull the original package from the canonical place with the standard go get command:
>
>
> `go get github.com/superseriousbusiness/gotosocial`
>
>
> Fork the repository on Github or set up whatever other remote git repo you will be using. In this case, I would go to Github and fork the repository.
>
>
> Navigate to the top level of the repository on your computer. Note that this might not be the specific package you’re using:
>
>
> `cd $GOPATH/src/github.com/superseriousbusiness/gotosocial`
>
>
> Rename the current origin remote to upstream:
>
>
> `git remote rename origin upstream`
>
>
> Add your fork as origin:
>
>
> `git remote add origin git@github.com/yourgithubname/gotosocial`
>
## Setting up your test environment

GoToSocial provides a [testrig](https://github.com/superseriousbusiness/gotosocial/tree/main/testrig) with a bunch of mock packages you can use in integration tests.

One thing that *isn't* mocked is the Database interface, because it's just easier to use a real Postgres database running on localhost.

You can spin up a Postgres easily using Docker:

```bash
docker run -d --user postgres --network host -e POSTGRES_PASSWORD=postgres postgres
```

If you want a nice interface for peeking at what's in the Postgres database during tests, use PGWeb:

```bash
docker run -d --user postgres --network host sosedoff/pgweb
```

This will launch a pgweb at `http://localhost:8081`.
One thing that *isn't* mocked is the Database interface, because it's just easier to use an in-memory SQLite database than to mock everything out.

### Standalone Testrig

You can also launch a testrig as a standalone server running at localhost, which you can connect to using something like [Pinafore](https://github.com/nolanlawson/pinafore).

To do this, first build the gotosocial binary with `go build ./cmd/gotosocial`.

Then launch a clean Postgres container on localhost:

```bash
docker run -d --user postgres --network host -e POSTGRES_PASSWORD=postgres postgres
```
To do this, first build the gotosocial binary with `./build.sh`.

Then, launch the testrig by invoking the binary as follows:

Expand All @@ -118,19 +98,19 @@ At the login screen, enter the email address `zork@example.org` and password `pa

Note the following constraints:

- The testrig data will be destroyed when the testrig is destroyed. It does this by dropping all tables in Postgres on shutdown. As such, you should **NEVER RUN THE TESTRIG AGAINST A DATABASE WITH REAL DATA IN IT** because it will be destroyed. Be especially careful if you're forwarding database ports from a remote instance to your local machine, because you can easily and irreversibly nuke that data if you run the testrig against it.
- Since the testrig uses an in-memory database, the database will be destroyed when the testrig is stopped.
- If you stop the testrig and start it again, any tokens or applications you created during your tests will also be removed. As such, you need to log out and in again every time you stop/start the rig.
- The testrig does not make any actual external http calls, so federation will (obviously) not work from a testrig.

## Running tests

Because the tests use a real Postgres under the hood, you can't run them in parallel, so you need to run tests with the following command:
Because the tests use a real SQLite database under the hood, you can't run them in parallel, so you need to run tests with the following command:

```bash
go test -count 1 -p 1 ./...
go test -p 1 ./...
```

The `count` flag means that tests will be run at least once, and the `-p 1` flag means that only 1 test will be run at a time.
The `-p 1` flag means that only 1 test will be run at a time.

## Linting

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# STEP ONE: build the GoToSocial binary
FROM golang:1.16.4-alpine3.13 AS binary_builder
FROM golang:1.17.1-alpine3.13 AS binary_builder
RUN apk update && apk upgrade --no-cache
RUN apk add git

Expand Down
110 changes: 76 additions & 34 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,68 +1,110 @@
module github.com/superseriousbusiness/gotosocial

go 1.16
go 1.17

require (
github.com/ReneKroon/ttlcache v1.7.0
github.com/buckket/go-blurhash v1.1.0
github.com/coreos/go-oidc/v3 v3.0.0
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/dsoprea/go-exif v0.0.0-20210625224831-a6301f85c82b // indirect
github.com/dsoprea/go-exif/v2 v2.0.0-20210625224831-a6301f85c82b // indirect
github.com/dsoprea/go-iptc v0.0.0-20200610044640-bc9ca208b413 // indirect
github.com/dsoprea/go-jpeg-image-structure v0.0.0-20210512043942-b434301c6836 // indirect
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/dsoprea/go-photoshop-info-format v0.0.0-20200610045659-121dd752914d // indirect
github.com/dsoprea/go-png-image-structure v0.0.0-20210512210324-29b889a6093d // indirect
github.com/dsoprea/go-utility v0.0.0-20200717064901-2fccff4aa15e // indirect
github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.7.2-0.20210722225815-d4ca9a0fb121
github.com/gin-gonic/gin v1.7.2-0.20210908033055-3a6f18f32f22
github.com/go-errors/errors v1.4.0 // indirect
github.com/go-fed/activity v1.0.1-0.20210803212804-d866ba75dd0f
github.com/go-fed/httpsig v1.1.0
github.com/go-playground/validator/v10 v10.7.0
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/go-playground/validator/v10 v10.9.0
github.com/google/uuid v1.3.0
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/websocket v1.4.2
github.com/h2non/filetype v1.1.1
github.com/jackc/pgconn v1.10.0
github.com/jackc/pgx/v4 v4.13.0
github.com/json-iterator/go v1.1.11 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/microcosm-cc/bluemonday v1.0.15
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
github.com/oklog/ulid v1.3.1
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b // indirect
github.com/russross/blackfriday/v2 v2.1.0
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.7.0
github.com/superseriousbusiness/exifremove v0.0.0-20210330092427-6acd27eac203
github.com/superseriousbusiness/oauth2/v4 v4.3.2-SSB
github.com/tdewolff/minify/v2 v2.9.21
github.com/tidwall/buntdb v1.2.4 // indirect
github.com/uptrace/bun v1.0.4
github.com/uptrace/bun/dialect/pgdialect v0.4.3
github.com/uptrace/bun/dialect/sqlitedialect v0.4.3
github.com/uptrace/bun v1.0.5
github.com/uptrace/bun/dialect/pgdialect v1.0.5
github.com/uptrace/bun/dialect/sqlitedialect v1.0.5
github.com/urfave/cli/v2 v2.3.0
github.com/wagslane/go-password-validator v0.3.0
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/mod v0.5.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f
golang.org/x/sys v0.0.0-20210908160347-a851e7ddeee0 // indirect
golang.org/x/text v0.3.6
golang.org/x/tools v0.1.5 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
golang.org/x/text v0.3.7
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
modernc.org/sqlite v1.13.0
mvdan.cc/xurls/v2 v2.3.0
)

require (
github.com/PuerkitoBio/goquery v1.7.1 // indirect
github.com/andybalholm/cascadia v1.2.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dsoprea/go-exif v0.0.0-20210625224831-a6301f85c82b // indirect
github.com/dsoprea/go-exif/v2 v2.0.0-20210625224831-a6301f85c82b // indirect
github.com/dsoprea/go-iptc v0.0.0-20200610044640-bc9ca208b413 // indirect
github.com/dsoprea/go-jpeg-image-structure v0.0.0-20210512043942-b434301c6836 // indirect
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/dsoprea/go-photoshop-info-format v0.0.0-20200610045659-121dd752914d // indirect
github.com/dsoprea/go-png-image-structure v0.0.0-20210512210324-29b889a6093d // indirect
github.com/dsoprea/go-utility v0.0.0-20200717064901-2fccff4aa15e // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect
github.com/goccy/go-json v0.7.8 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/context v1.1.1 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/securecookie v1.1.1 // indirect
github.com/gorilla/sessions v1.2.1 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgproto3/v2 v2.1.1 // indirect
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
github.com/jackc/pgtype v1.8.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/quasoft/memstore v0.0.0-20191010062613-2bce066d2b0b // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/tdewolff/parse/v2 v2.5.19 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
golang.org/x/mod v0.5.0 // indirect
golang.org/x/net v0.0.0-20210908191846-a5e095526f91 // indirect
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3 // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
lukechampine.com/uint128 v1.1.1 // indirect
modernc.org/cc/v3 v3.34.0 // indirect
modernc.org/ccgo/v3 v3.11.2 // indirect
modernc.org/libc v1.11.3 // indirect
modernc.org/mathutil v1.4.1 // indirect
modernc.org/memory v1.0.5 // indirect
modernc.org/opt v0.1.1 // indirect
modernc.org/strutil v1.1.1 // indirect
modernc.org/token v1.0.0 // indirect
)
Loading

0 comments on commit f2e5bed

Please sign in to comment.