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

Added Format CI and Release CD #52

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
69 changes: 69 additions & 0 deletions .github/workflows/cd-create-release-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Create Release Notes

on:
workflow_dispatch:
inputs:
version:
description: 'SemVer format release tag, i.e. 0.2.4'
required: true
repository_dispatch:
types: [ release-notes ]

jobs:
create-release-notes:
runs-on: ubuntu-22.04
steps:
- name: Get Vars
id: get_vars
run: |
if [ "$EVENT_NAME" == "workflow_dispatch" ]
then
release_id=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/dolthub/doltgresql/releases/tags/v${{ github.event.inputs.version }} | jq '.id')
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
echo "release_id=$release_id" >> $GITHUB_OUTPUT
else
echo "version=${{ github.event.client_payload.version }}" >> $GITHUB_OUTPUT
echo "release_id=${{ github.event.client_payload.release_id }}" >> $GITHUB_OUTPUT
fi
env:
EVENT_NAME: ${{ github.event_name }}
- name: Checkout Release Notes Generator
uses: actions/checkout@v3
with:
repository: dolthub/release-notes-generator
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Install Dependencies
run: sudo ./install-deps.sh
env:
PERL_MM_USE_DEFAULT: 1
- name: Create Notes
run: |
git clone https://github.com/dolthub/doltgresql.git
./gen_release_notes.pl \
--token "$TOKEN" dolthub/doltgresql v${{ steps.get_vars.outputs.version }} > changelog.txt
env:
TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Post Changelog to Release
uses: actions/github-script@v6
with:
debug: true
github-token: ${{ secrets.REPO_ACCESS_TOKEN }}
script: |
const fs = require('fs');
const path = require('path')
try {
const body = fs.readFileSync(path.join(process.env.WORKSPACE, "changelog.txt"), { encoding: "utf8" })
const res = await github.rest.repos.updateRelease({
owner: "dolthub",
repo: "doltgresql",
release_id: parseInt(process.env.RELEASE_ID, 10),
body,
});
console.log("Successfully updated release notes", res)
} catch (err) {
console.log("Error", err);
process.exit(1);
}
env:
WORKSPACE: ${{ github.workspace }}
RELEASE_ID: ${{ steps.get_vars.outputs.release_id }}
137 changes: 137 additions & 0 deletions .github/workflows/cd-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
name: Release DoltgreSQL

on:
workflow_dispatch:
inputs:
version:
description: 'SemVer format release tag, i.e. 0.2.4'
required: true

jobs:
format-version:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.format_version.outputs.version }}
steps:
- name: Format Input
id: format_version
run: |
version="${{ github.event.inputs.version }}"
if [[ $version == v* ]];
then
version="${version:1}"
fi
echo "version=$version" >> $GITHUB_OUTPUT

create-release:
needs: format-version
name: Create release
runs-on: ubuntu-22.04
outputs:
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Update Doltgres version command
run: sed -i -e 's/ Version = ".*"/ Version = "'"$NEW_VERSION"'"/' "$FILE"
env:
FILE: ${{ format('{0}/server/server.go', github.workspace) }}
NEW_VERSION: ${{ needs.format-version.outputs.version }}
- uses: EndBug/[email protected]
with:
message: ${{ format('[ga-bump-release] Update DoltgreSQL version to {0} and release v{0}', needs.format-version.outputs.version) }}
add: ${{ format('{0}/server/server.go', github.workspace) }}
cwd: "."
pull: "--ff"
- name: Build SQL Syntax
run: ./build.sh
working-directory: ./postgres/parser
shell: bash
- name: Build Binaries
id: build_binaries
run: |
latest=$(git rev-parse HEAD)
echo "commitish=$latest" >> $GITHUB_OUTPUT
GO_BUILD_VERSION=1.21 scripts/build_binaries.sh
- name: Create Release
id: create_release
uses: dolthub/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.format-version.outputs.version }}
release_name: ${{ needs.format-version.outputs.version }}
draft: false
prerelease: true
commitish: ${{ steps.build_binaries.outputs.commitish }}
- name: Upload Linux AMD64 Distro
id: upload-linux-amd64-distro
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-linux-amd64.tar.gz
asset_name: doltgres-linux-amd64.tar.gz
asset_content_type: application/zip
- name: Upload Linux ARM64 Distro
id: upload-linux-arm64-distro
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-linux-arm64.tar.gz
asset_name: doltgres-linux-arm64.tar.gz
asset_content_type: application/zip
- name: Upload OSX AMD64 Distro
id: upload-osx-amd64-distro
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-darwin-amd64.tar.gz
asset_name: doltgres-darwin-amd64.tar.gz
asset_content_type: application/zip
- name: Upload OSX ARM64 Distro
id: upload-osx-arm64-distro
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-darwin-arm64.tar.gz
asset_name: doltgres-darwin-arm64.tar.gz
asset_content_type: application/zip
- name: Upload Windows Distro
id: upload-windows-distro
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-windows-amd64.zip
asset_name: doltgres-windows-amd64.zip
asset_content_type: application/zip
- name: Upload Windows Distro 7z
id: upload-windows-distro-7z
uses: dolthub/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: out/doltgres-windows-amd64.7z
asset_name: doltgres-windows-amd64.7z
asset_content_type: application/x-7z-compressed

create-release-notes:
needs: [format-version, create-release]
runs-on: ubuntu-22.04
steps:
- name: Trigger Release Notes
uses: peter-evans/[email protected]
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: release-notes
client-payload: '{"version": "${{ needs.format-version.outputs.version }}", "release_id": "${{ needs.create-release.outputs.release_id }}"}'
42 changes: 42 additions & 0 deletions .github/workflows/ci-check-repo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Check Formatting, Committers and Generated Code

on:
pull_request:
branches: [ main ]

concurrency:
group: ci-check-repo-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify format
runs-on: ubuntu-22.04
outputs:
format: ${{ steps.should_format.outputs.format }}
steps:
- name: Setup Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.21
- uses: actions/checkout@v3
with:
submodules: true
- name: Check all
id: should_format
run: |
./scripts/check_bats_fmt.sh

if ./scripts/check_fmt.sh ; then
echo "code is formatted"
else
echo "Please run scripts/format_repo.sh to format this pull request."
exit 1;
fi

./postgres/parser/build.sh
GOFLAGS="-mod=readonly" go build ./...
go vet -mod=readonly ./...
env:
BRANCH_NAME: ${{ github.head_ref }}
CHANGE_TARGET: ${{ github.base_ref }}
2 changes: 1 addition & 1 deletion postgres/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/dolthub/doltgresql/utils"
)

//TODO: determine how to handle messages that are larger than the buffer
// TODO: determine how to handle messages that are larger than the buffer
const bufferSize = 2048

// connBuffers maintains a pool of buffers, reusable between connections.
Expand Down
31 changes: 16 additions & 15 deletions postgres/parser/encoding/decimal.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,9 @@ func decodeLargeNumber(
// EncodeNonsortingDecimal returns the resulting byte slice with the
// encoded decimal appended to b. The encoding is limited compared to
// standard encodings in this package in that
// - It will not sort lexicographically
// - It does not encode its length or terminate itself, so decoding
// functions must be provided the exact encoded bytes
// - It will not sort lexicographically
// - It does not encode its length or terminate itself, so decoding
// functions must be provided the exact encoded bytes
//
// The encoding assumes that any number can be written as ±0.xyz... * 10^exp,
// where xyz is a digit string, x != 0, and the last decimal in xyz is also
Expand All @@ -525,21 +525,22 @@ func decodeLargeNumber(
// the digit string is added as a big-endian byte slice.
//
// All together, the encoding looks like:
// <marker><uvarint exponent><big-endian encoded big.Int>.
//
// <marker><uvarint exponent><big-endian encoded big.Int>.
//
// The markers are shared with the sorting decimal encoding as follows:
// decimalNaN -> decimalNaN
// decimalNegativeInfinity -> decimalNegativeInfinity
// decimalNegLarge -> decimalNegValPosExp
// decimalNegMedium -> decimalNegValZeroExp
// decimalNegSmall -> decimalNegValNegExp
// decimalZero -> decimalZero
// decimalPosSmall -> decimalPosValNegExp
// decimalPosMedium -> decimalPosValZeroExp
// decimalPosLarge -> decimalPosValPosExp
// decimalInfinity -> decimalInfinity
// decimalNaNDesc -> decimalNaNDesc
//
// decimalNaN -> decimalNaN
// decimalNegativeInfinity -> decimalNegativeInfinity
// decimalNegLarge -> decimalNegValPosExp
// decimalNegMedium -> decimalNegValZeroExp
// decimalNegSmall -> decimalNegValNegExp
// decimalZero -> decimalZero
// decimalPosSmall -> decimalPosValNegExp
// decimalPosMedium -> decimalPosValZeroExp
// decimalPosLarge -> decimalPosValPosExp
// decimalInfinity -> decimalInfinity
// decimalNaNDesc -> decimalNaNDesc
func EncodeNonsortingDecimal(b []byte, d *apd.Decimal) []byte {
neg := d.Negative
switch d.Form {
Expand Down
25 changes: 15 additions & 10 deletions postgres/parser/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ const (
// The gap between floatNaNDesc and bytesMarker was left for
// compatibility reasons.
bytesMarker byte = 0x12
bytesDescMarker byte = bytesMarker + 1
timeMarker byte = bytesDescMarker + 1
durationBigNegMarker byte = timeMarker + 1 // Only used for durations < MinInt64 nanos.
durationMarker byte = durationBigNegMarker + 1
durationBigPosMarker byte = durationMarker + 1 // Only used for durations > MaxInt64 nanos.
bytesDescMarker = bytesMarker + 1
timeMarker = bytesDescMarker + 1
durationBigNegMarker = timeMarker + 1 // Only used for durations < MinInt64 nanos.
durationMarker = durationBigNegMarker + 1
durationBigPosMarker = durationMarker + 1 // Only used for durations > MaxInt64 nanos.

decimalNaN = durationBigPosMarker + 1 // 24
decimalNegativeInfinity = decimalNaN + 1
Expand Down Expand Up @@ -569,6 +569,7 @@ func getBitArrayWordsLen(b []byte, term byte) (int, int, error) {

// Type represents the type of a value encoded by
// Encode{Null,NotNull,Varint,Uvarint,Float,Bytes}.
//
//go:generate stringer -type=Type
type Type int

Expand Down Expand Up @@ -912,12 +913,16 @@ func EncodeUntaggedDecimalValue(appendTo []byte, d *apd.Decimal) []byte {
// returned colID should be discarded.)
//
// Concretely:
// b := ...
// typeOffset, _, colID, typ, err := DecodeValueTag(b)
// _, _, _, typ, err := DecodeValueTag(b[typeOffset:])
//
// b := ...
// typeOffset, _, colID, typ, err := DecodeValueTag(b)
// _, _, _, typ, err := DecodeValueTag(b[typeOffset:])
//
// will return the same typ and err and
// DecodeFooValue(b)
// DecodeFooValue(b[typeOffset:])
//
// DecodeFooValue(b)
// DecodeFooValue(b[typeOffset:])
//
// will return the same thing. PeekValueLength works as expected with either of
// `b` or `b[typeOffset:]`.
func DecodeValueTag(b []byte) (typeOffset int, dataOffset int, colID uint32, typ Type, err error) {
Expand Down
2 changes: 1 addition & 1 deletion postgres/parser/errorutil/unimplemented/unimplemented.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func NewWithIssueDetailf(issue int, detail, format string, args ...interface{})
return unimplementedInternal(1 /*depth*/, issue, detail, true /*format*/, format, args...)
}

//TODO: remove issue int
// TODO: remove issue int
func unimplementedInternal(depth, issue int, detail string, format bool, msg string, args ...interface{}) error {
// Create the issue link.
link := errors.IssueLink{Detail: detail}
Expand Down
3 changes: 2 additions & 1 deletion postgres/parser/geo/geo.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,8 @@ func AdjustGeomTSRID(t geom.T, srid geopb.SRID) {
// IsLinearRingCCW returns whether a given linear ring is counter clock wise.
// See 2.07 of http://www.faqs.org/faqs/graphics/algorithms-faq/.
// "Find the lowest vertex (or, if there is more than one vertex with the same lowest coordinate,
// the rightmost of those vertices) and then take the cross product of the edges fore and aft of it."
//
// the rightmost of those vertices) and then take the cross product of the edges fore and aft of it."
func IsLinearRingCCW(linearRing *geom.LinearRing) bool {
smallestIdx := 0
smallest := linearRing.Coord(0)
Expand Down
4 changes: 2 additions & 2 deletions postgres/parser/geo/geopb/geopb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ message SpatialObject {
// Type is the type of the SpatialObject.
SpatialObjectType type = 1;
// EWKB is the EWKB representation of the spatial object.
bytes ewkb = 2 [(gogoproto.customname)="EWKB",(gogoproto.casttype)="EWKB"];
bytes ewkb = 2 [(gogoproto.customname) = "EWKB", (gogoproto.casttype) = "EWKB"];
// SRID is the denormalized SRID derived from the EWKB.
int32 srid = 3 [(gogoproto.customname)="SRID",(gogoproto.casttype)="SRID"];
int32 srid = 3 [(gogoproto.customname) = "SRID", (gogoproto.casttype) = "SRID"];
// ShapeType is denormalized ShapeType derived from the EWKB.
ShapeType shape_type = 4;
// BoundingBox is the bounding box of the SpatialObject.
Expand Down
Loading