-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dev/coverage-collapsibility
- Loading branch information
Showing
123 changed files
with
4,087 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ on: | |
push: | ||
branches: | ||
- master | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: | ||
- master | ||
|
@@ -22,7 +24,10 @@ jobs: | |
needs: [lint, test] | ||
strategy: | ||
matrix: | ||
environment: [ubuntu-latest, macos-latest, windows-latest] | ||
environment: [ubuntu-latest, macos-12, macos-14, windows-latest] | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
runs-on: ${{ matrix.environment }} | ||
timeout-minutes: 10 | ||
|
@@ -44,32 +49,76 @@ jobs: | |
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV" | ||
go env | ||
- uses: actions/setup-go@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.18.1" | ||
# disable caching during release (tag) builds | ||
cache: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
|
||
- name: Build (Linux and macOS) | ||
if: runner.os == 'Linux' || runner.os == 'macOS' | ||
run: go build -o medusa -v . | ||
|
||
- name: Compress (Linux and macOS) | ||
if: runner.os == 'Linux' || runner.os == 'macOS' | ||
run: tar -czvf medusa.tar.gz medusa | ||
run: tar -czvf medusa-${{ runner.os }}-${{ runner.arch }}.tar.gz medusa | ||
|
||
- name: Build (Windows) | ||
if: runner.os == 'Windows' | ||
run: go build -o medusa.exe -v . | ||
|
||
- name: Compress (Windows) | ||
if: runner.os == 'Windows' | ||
run: tar -czvf medusa.tar.gz medusa.exe | ||
run: tar -czvf medusa-${{ runner.os }}-${{ runner.arch }}.tar.gz medusa.exe | ||
|
||
- name: Upload artifact on merge to master | ||
if: github.ref == 'refs/heads/master' | ||
uses: actions/upload-artifact@v3 | ||
- name: Rename for release | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
shell: bash | ||
run: | | ||
[ ! -f medusa-Linux-X64.tar.gz ] || mv medusa-Linux-X64.tar.gz medusa-linux-x64.tar.gz | ||
[ ! -f medusa-macOS-X64.tar.gz ] || mv medusa-macOS-X64.tar.gz medusa-mac-x64.tar.gz | ||
[ ! -f medusa-macOS-ARM64.tar.gz ] || mv medusa-macOS-ARM64.tar.gz medusa-mac-arm64.tar.gz | ||
[ ! -f medusa-Windows-X64.tar.gz ] || mv medusa-Windows-X64.tar.gz medusa-win-x64.tar.gz | ||
- name: Sign artifact | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: ./medusa-*.tar.gz | ||
|
||
- name: Upload artifact | ||
if: github.ref == 'refs/heads/master' || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: medusa-${{ runner.os }} | ||
path: medusa.tar.gz | ||
name: medusa-${{ runner.os }}-${{ runner.arch }} | ||
path: | | ||
./medusa-*.tar.gz | ||
./medusa-*.tar.gz.sigstore | ||
release: | ||
needs: [build] | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
permissions: | ||
contents: write | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
|
||
steps: | ||
- name: Download binaries | ||
uses: actions/download-artifact@v4 | ||
with: | ||
pattern: medusa-* | ||
merge-multiple: true | ||
|
||
- name: Create GitHub release and upload binaries | ||
uses: softprops/action-gh-release@9d7c94cfd0a1f3ed45544c887983e9fa900f0564 # v2.0.4 | ||
with: | ||
draft: true | ||
name: "${{ github.ref_name }}" | ||
files: | | ||
./medusa-*.tar.gz | ||
./medusa-*.tar.gz.sigstore | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
@@ -78,7 +127,7 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.18.1" | ||
|
||
|
@@ -110,14 +159,18 @@ jobs: | |
test: | ||
strategy: | ||
matrix: | ||
environment: [ubuntu-latest, macos-latest, windows-latest] | ||
environment: [ubuntu-latest, macos-12, macos-14, windows-latest] | ||
|
||
runs-on: ${{ matrix.environment }} | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.10" | ||
|
||
- name: Speed up Go, Python, Node (Windows) | ||
if: runner.os == 'Windows' | ||
run: | | ||
|
@@ -142,11 +195,11 @@ jobs: | |
npm config set cache "$DIR\\npm-cache" --global | ||
echo "::endgroup::" | ||
- uses: actions/setup-go@v4 | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: "^1.18.1" | ||
|
||
- uses: actions/setup-node@v3 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18.15 | ||
|
||
|
@@ -155,7 +208,7 @@ jobs: | |
|
||
- name: Install Python dependencies | ||
run: | | ||
pip3 install --no-cache-dir setuptools solc-select crytic-compile | ||
pip3 install --no-cache-dir solc-select crytic-compile | ||
- name: Install solc | ||
run: | | ||
|
@@ -165,9 +218,14 @@ jobs: | |
run: go test ./... | ||
|
||
all-checks: | ||
needs: [lint, test, build] | ||
if: always() | ||
needs: [lint, test, build, release] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- run: true | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 | ||
with: | ||
allowed-skips: release | ||
jobs: ${{ toJSON(needs) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,7 @@ | |
*node_modules/ | ||
|
||
# Medusa binary | ||
medusa | ||
medusa | ||
|
||
# Medusa docs | ||
docs/book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package exitcodes | ||
|
||
// ErrorWithExitCode is an `error` type that wraps an existing error and exit code, providing exit codes | ||
// for a given error if they are bubbled up to the top-level. | ||
type ErrorWithExitCode struct { | ||
err error | ||
exitCode int | ||
} | ||
|
||
// NewErrorWithExitCode creates a new error (ErrorWithExitCode) with the provided internal error and exit code. | ||
func NewErrorWithExitCode(err error, exitCode int) *ErrorWithExitCode { | ||
return &ErrorWithExitCode{ | ||
err: err, | ||
exitCode: exitCode, | ||
} | ||
} | ||
|
||
// Error returns the error message string, implementing the `error` interface. | ||
func (e *ErrorWithExitCode) Error() string { | ||
if e.err == nil { | ||
return "" | ||
} | ||
return e.err.Error() | ||
} | ||
|
||
// GetInnerErrorAndExitCode checks the given exit code that the application should exit with, if this error is bubbled | ||
// to the top-level. This will be 0 for a nil error, 1 for a generic error, or arbitrary if the error is of type | ||
// ErrorWithExitCode. | ||
// Returns the error (or inner error if it is an ErrorWithExitCode error type), along with the exit code associated | ||
// with the error. | ||
func GetInnerErrorAndExitCode(err error) (error, int) { | ||
// If we have no error, return 0, if we have a generic error, return 1, if we have a custom error code, unwrap | ||
// and return it. | ||
if err == nil { | ||
return nil, ExitCodeSuccess | ||
} else if unwrappedErr, ok := err.(*ErrorWithExitCode); ok { | ||
return unwrappedErr.err, unwrappedErr.exitCode | ||
} else { | ||
return err, ExitCodeGeneralError | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package exitcodes | ||
|
||
const ( | ||
// ================================ | ||
// Platform-universal exit codes | ||
// ================================ | ||
|
||
// ExitCodeSuccess indicates no errors or failures had occurred. | ||
ExitCodeSuccess = 0 | ||
|
||
// ExitCodeGeneralError indicates some type of general error occurred. | ||
ExitCodeGeneralError = 1 | ||
|
||
// ================================ | ||
// Application-specific exit codes | ||
// ================================ | ||
// Note: Despite not being standardized, exit codes 2-5 are often used for common use cases, so we avoid them. | ||
|
||
// ExitCodeHandledError indicates that there was an error that was logged already and does not need to be handled | ||
// by main. | ||
ExitCodeHandledError = 6 | ||
|
||
// ExitCodeTestFailed indicates a test case had failed. | ||
ExitCodeTestFailed = 7 | ||
) |
Oops, something went wrong.