diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..d603025 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,30 @@ +--- +name: Report a bug +about: Something with blob-hub is not working as expected +title: '' +labels: 'type:bug' +assignees: '' +--- + +#### System information + +Blob syncer version: (if getting from release page) +OS & Version: Windows/Linux/OSX +Commit hash : (if `develop`) + +#### Expected behaviour + + +#### Actual behaviour + + +#### Steps to reproduce the behaviour + + +#### Backtrace + +```` +[backtrace] +```` + +When submitting logs: please submit them as text and not screenshots. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature.md b/.github/ISSUE_TEMPLATE/feature.md new file mode 100644 index 0000000..aacd885 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.md @@ -0,0 +1,17 @@ +--- +name: Request a feature +about: Report a missing feature - e.g. as a step before submitting a PR +title: '' +labels: 'type:feature' +assignees: '' +--- + +# Rationale + +Why should this feature exist? +What are the use-cases? + +# Implementation + +Do you have ideas regarding the implementation of this feature? +Are you willing to implement this feature? \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..f2f3022 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,9 @@ +--- +name: Ask a question +about: Something is unclear +title: '' +labels: 'type:docs' +assignees: '' +--- + +This should only be used in very rare cases e.g. if you are not 100% sure if something is a bug or asking a question that leads to improving the documentation. For general questions please use [discord](https://discord.gg/bnbchain). diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d9bdc91 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +### Description + +add a description of your changes here... + +### Rationale + +tell us why we need these changes... + +### Example + +add an example CLI or API response... + +### Changes + +Notable changes: +* add each change in a bullet point here +* ... \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..5774b7b --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: Build Test + +on: + push: + branches: + - master + - develop + + pull_request: + branches: + - master + - develop + +jobs: + build-test: + strategy: + matrix: + go-version: [1.22.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + env: + GOPRIVATE: github.com/bnb-chain + GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }} + steps: + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v3 + + - uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Setup GitHub Token + run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ + + - name: Test Build + run: | + make build diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 0000000..47b8913 --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,56 @@ +name: Docker + +on: + push: + # Publish `v1.2.3` tags as releases. + tags: + - v* + +env: + IMAGE_NAME: ghcr.io/${{ github.repository }} + IMAGE_SOURCE: https://github.com/${{ github.repository }} + +jobs: + # Push image to GitHub Packages. + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v3 + + - name: Build image + run: | + docker build . \ + --label "org.opencontainers.image.source=${IMAGE_SOURCE}" \ + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ + --label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \ + -f ./server-distroless.dockerfile -t "${IMAGE_NAME}:server-distroless" + + docker build . \ + --label "org.opencontainers.image.source=${IMAGE_SOURCE}" \ + --label "org.opencontainers.image.revision=$(git rev-parse HEAD)" \ + --label "org.opencontainers.image.version=$(git describe --tags --abbrev=0)" \ + -f ./syncer-distroless.dockerfile -t "${IMAGE_NAME}:syncer-distroless" + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GH_TOKEN }} + + - name: Push image + run: | + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_NAME=$IMAGE_NAME + echo VERSION=$VERSION + docker tag ${IMAGE_NAME}:server-distroless $IMAGE_NAME:$VERSION-server-distroless + docker tag ${IMAGE_NAME}:syncer-distroless $IMAGE_NAME:$VERSION-syncer-distroless + docker push $IMAGE_NAME:$VERSION-server-distroless + docker push $IMAGE_NAME:$VERSION-syncer-distroless \ No newline at end of file diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml new file mode 100644 index 0000000..d4d39d2 --- /dev/null +++ b/.github/workflows/gosec.yml @@ -0,0 +1,51 @@ +name: gosec + +on: + push: + branches: + - master + - develop + pull_request: + branches: + - master + - develop +jobs: + gosec: + name: gosec + strategy: + matrix: + go-version: [1.22.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + env: + GOPRIVATE: github.com/bnb-chain + GH_ACCESS_TOKEN: ${{ secrets.GH_TOKEN }} + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v3 + - name: Setup GitHub Token + run: git config --global url.https://$GH_ACCESS_TOKEN@github.com/.insteadOf https://github.com/ + - uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - run: | + go mod tidy + go mod download + - name: Run Gosec Security Scanner + uses: securego/gosec@master + with: + args: -quiet -confidence high -severity high ./... \ No newline at end of file diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml new file mode 100644 index 0000000..b2dea88 --- /dev/null +++ b/.github/workflows/lint-pr.yml @@ -0,0 +1,30 @@ +name: "Lint PR" + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + with: + types: | + feat + fix + docs + style + refactor + perf + test + build + ci + chore + revert + release diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..6ba7d44 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,55 @@ +name: Lint +on: + push: + branches: + - master + - develop + pull_request: +permissions: + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + # pull-requests: read +jobs: + golangci: + name: golangci-lint + strategy: + matrix: + go-version: [1.22.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + env: + GOPRIVATE: github.com/bnb-chain + steps: + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - uses: actions/checkout@v3 + + - run: go env -w GOPRIVATE="github.com/bnb-chain/*" + - run: git config --global url."https://${{ secrets.GH_TOKEN }}@github.com".insteadOf "https://github.com" + + - uses: actions/cache@v3 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + # * Build cache (Mac) + # * Build cache (Windows) + path: | + ~/go/pkg/mod + ~/.cache/go-build + ~/Library/Caches/go-build + %LocalAppData%\go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - run: | + go mod tidy + go mod download + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + skip-pkg-cache: true + args: --timeout=99m diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..82284f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM alpine + +WORKDIR /build + +COPY monitor . + +CMD ["./monitor"] \ No newline at end of file