Skip to content

Commit

Permalink
Merge pull request #3 from mliezun/feature/release-rust
Browse files Browse the repository at this point in the history
Feature/release rust
  • Loading branch information
mliezun authored Oct 26, 2023
2 parents e15139e + a3c2c13 commit 6895e13
Show file tree
Hide file tree
Showing 4 changed files with 167 additions and 94 deletions.
69 changes: 43 additions & 26 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,49 @@ on:
- master

jobs:
build:
name: Build
test_go:
name: Test Go version
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./cmd/grotsky/

- name: Test
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic github.com/mliezun/grotsky/internal
bash <(curl -s https://codecov.io/bash)
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./cmd/grotsky/

- name: Test
run: |
go test -v -race -coverprofile=coverage.txt -covermode=atomic github.com/mliezun/grotsky/internal
bash <(curl -s https://codecov.io/bash)
test_rust:
name: Test Rust version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install deps
run: sudo apt-get install make

- name: Test
run: make test_grotsky-rs
188 changes: 122 additions & 66 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,126 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.15
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Build
run: |
GOOS=linux GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-linux ./cmd/grotsky/
GOOS=darwin GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-macos ./cmd/grotsky/
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Prepare Release Linux
run: |
mv grotsky-linux grotsky
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz grotsky
- name: Prepare Release Mac
run: |
mv grotsky-macos grotsky
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz grotsky
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
release_name: Release ${{ steps.extract_branch.outputs.branch }}
body: |
Automated Release
draft: false
prerelease: false

- name: Upload Release Linux
id: upload-release-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_content_type: application/gzip

- name: Upload Release Mac
id: upload-release-macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz
asset_content_type: application/gzip
- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
run: go get -v -t -d ./...

- name: Build
run: |
GOOS=linux GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-linux ./cmd/grotsky/
GOOS=darwin GOARCH=amd64 go build -ldflags '-extldflags "-fno-PIC -static"' -buildmode pie -tags 'osusergo netgo static_build' -o grotsky-macos ./cmd/grotsky/
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Prepare Release Linux
run: |
mv grotsky-linux grotsky
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz grotsky
- name: Prepare Release Mac
run: |
mv grotsky-macos grotsky
tar -czvf grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz grotsky
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
release_name: Release ${{ steps.extract_branch.outputs.branch }}
body: |
Automated Release
draft: false
prerelease: false

- name: Upload Release Linux
id: upload-release-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_content_type: application/gzip

- name: Upload Release Mac
id: upload-release-macos
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz
asset_name: grotsky-${{ steps.extract_branch.outputs.branch }}-macos-x86_64.tar.gz
asset_content_type: application/gzip

build_rust:
name: Build Rust version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install latest stable
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
components: rustfmt, clippy

- name: Install deps
run: |
sudo apt-get install make
rustup target add x86_64-apple-darwin
- name: Build for linux
run: |
cd rewrite_in_rust
cargo build --release
mv target/release/grotsky-rs ../grotsky-rs-linux
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch

- name: Prepare Release Linux
run: |
mv grotsky-rs-linux grotsky
tar -czvf grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz grotsky
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
release_name: Release ${{ steps.extract_branch.outputs.branch }}
body: |
Automated Release
draft: false
prerelease: false

- name: Upload Release Linux
id: upload-release-linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_name: grotsky-rs-${{ steps.extract_branch.outputs.branch }}-linux-x86_64.tar.gz
asset_content_type: application/gzip
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ grotsky:
@ mv main $(BUILD_DIR)/grotsky

grotsky-rs:
@ cd rewrite_in_rust && cargo build --release && cp target/release/grotsky-rs ../$(BUILD_DIR)/grotsky-rs
@ cd rewrite_in_rust && cargo build --release
2 changes: 1 addition & 1 deletion internal/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func run_code(absPath, source string, p IPrinter) bool {
}
case "Rust":
{
b := BinaryInterpreter{path: "build/grotsky-rs", buffer: make([]byte, 0)}
b := BinaryInterpreter{path: "rewrite_in_rust/target/release/grotsky-rs", buffer: make([]byte, 0)}
return b.RunSourceWithPrinter(absPath, source, p)
}
default:
Expand Down

0 comments on commit 6895e13

Please sign in to comment.