Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nix
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Jan 2, 2025
2 parents aa8abe5 + 878b0f1 commit cc78b49
Show file tree
Hide file tree
Showing 219 changed files with 13,367 additions and 2,621 deletions.
160 changes: 134 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches:
- master
Expand All @@ -13,53 +15,120 @@ concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
build:
needs: [lint, test]
strategy:
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
environment: [ubuntu-latest, macos-13, macos-14, windows-latest]
permissions:
contents: read
id-token: write

runs-on: ${{ matrix.environment }}
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
- name: Speed up Go (Windows)
if: runner.os == 'Windows'
run: |
DIR='D:\a\local'
mkdir -p "$DIR" && cd "$DIR"
mkdir go go-cache go-tmp tmpdir
go env -w GOPATH="$DIR\\go"
go env -w GOCACHE="$DIR\\go-cache"
go env -w GOTMPDIR="$DIR\\go-tmp"
printf '%s\\go\\bin\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'TMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
go env
- uses: actions/setup-go@v5
with:
go-version: "^1.18.1"
go-version: "^1.22"
# 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:
name: medusa-${{ runner.os }}
path: medusa.tar.gz
inputs: ./medusa-*.tar.gz

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: medusa-${{ runner.os }}-${{ runner.arch }}
path: |
./medusa-*.tar.gz
./medusa-*.tar.gz.sigstore.json
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.json
lint:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: "^1.18.1"
go-version: "^1.22"

- name: Actionlint
run: |
Expand All @@ -86,44 +155,83 @@ jobs:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint run --timeout 5m0s
- name: Gencodec
run: |
go get github.com/fjl/gencodec
pushd fuzzing/config
go run github.com/fjl/gencodec -type FuzzingConfig -field-override fuzzingConfigMarshaling -out gen_fuzzing_config.go
git diff --exit-code -- .
popd
test:
strategy:
matrix:
environment: [ubuntu-latest, macos-latest, windows-latest]
environment: [ubuntu-latest, macos-13, macos-14, windows-latest]

runs-on: ${{ matrix.environment }}
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v3
- uses: actions/setup-python@v5
with:
go-version: "^1.18.1"
python-version: "3.10"

- uses: actions/setup-node@v3
- name: Speed up Go, Python, Node (Windows)
if: runner.os == 'Windows'
run: |
DIR='D:\a\local'
mkdir -p "$DIR" && cd "$DIR"
echo "::group::Go"
mkdir -p go go-cache go-tmp tmpdir
go env -w GOPATH="$DIR\\go"
go env -w GOCACHE="$DIR\\go-cache"
go env -w GOTMPDIR="$DIR\\go-tmp"
printf '%s\\go\\bin\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'TMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
printf 'TEMP=%s\\tmpdir\n' "$DIR" | tee -a "$GITHUB_ENV"
go env
echo "::endgroup::"
echo "::group::Python"
python3 -m venv venv
printf '%s\\venv\\Scripts\n' "$DIR" | tee -a "$GITHUB_PATH"
printf 'VIRTUAL_ENV=%s\\venv\n' "$DIR" | tee -a "$GITHUB_ENV"
echo "::endgroup::"
echo "::group::Node"
npm config set cache "$DIR\\npm-cache" --global
echo "::endgroup::"
- uses: actions/setup-go@v5
with:
go-version: "^1.22"

- uses: actions/setup-node@v4
with:
node-version: 18.15

- name: Install Node dependencies
run: npm install -g hardhat truffle
run: npm install hardhat

- name: Install Python dependencies
run: |
pip3 install solc-select
pip3 install slither-analyzer
pip3 install --no-cache-dir solc-select crytic-compile
- name: Install solc
run: |
solc-select install 0.8.17
solc-select use 0.8.17
solc-select use 0.8.17 --always-install
- name: Test
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) }}
10 changes: 8 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@

# Dependency directories (remove the comment below to include it)
# vendor/
*node_modules/

# PyCharm project dir
# Goland project dir
.idea/

# Build results
result
*node_modules/

# Medusa binary
medusa

# Medusa docs
docs/book
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Xenomega @anishnaik
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To better understand how to make responsible open source contributions, consider
When introducing changes to the project, note the following requirements:

- All changes to the main branch should be introduced via pull requests.
- All branches created for pull requests should follow the `dev/*` naming convention, e.g. `dev/coverage-reports`.
- Every pull request **must** be reviewed by at least one other peer prior to being merged into the main branch.
- Code **must** be supported on Linux, macOS, and Windows.
- Code **must** be sufficiently commented:
Expand All @@ -33,6 +34,47 @@ If any of these requirements are violated, you should expect your pull request t

Pull request reviewers have a responsibility to uphold these standards. Even if a pull request is compliant with these requirements, a reviewer which identifies an opportunity to document some caveat (such as a `// TODO: ` comment) should request it be added prior to pull request approval.

### Linters

Several linters and security checkers are run on the PRs.

#### Go

To install

- `go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest`

To run

- `go fmt ./...`
- `golangci-lint run --timeout 5m0s`

#### Markdown/Json/Yaml

To install

- `npm install -g prettier`
- `npm install -g [email protected]`

To run

- `prettier '**.json' '**/*.md' '**/*.yml' '!(pkg)'`
- `find . -name '*.md' -print0 | xargs -0 -n1 markdown-link-check --config .github/workflows/resources/markdown_link_check.json`

To format (overwrite files)

- `prettier '**.json' '**/*.md' '**/*.yml' '!(pkg)' -w`

#### Github action

To install

- `go install github.com/rhysd/actionlint/cmd/actionlint@latest`

To run

- `actionlint`

### Cross-platform considerations

- Ensure file/directory names do not exceed 32 characters in length to minimize filepath length issues on Windows. File/directory names should be shorter than this where possible.
Expand Down
Loading

0 comments on commit cc78b49

Please sign in to comment.