From 6e12493623f369750d687ef6c44af439de2b971f Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Fri, 21 May 2021 18:45:01 +0300 Subject: [PATCH 1/2] [#51] *: Add github workflows File have been taken from neofs-http-gw. Commit 9604f9f4b16bbe211cf967c6d270ecb412fb0a208. Signed-off-by: Angira Kekteeva --- .github/workflows/builds.yml | 70 ++++++++++++++++++ .github/workflows/codeql-analysis.yml | 67 +++++++++++++++++ .github/workflows/dco.yml | 21 ++++++ .github/workflows/publish_to_dockerhub.yml | 84 +++++++++++++++++++++ .github/workflows/tests.yml | 86 ++++++++++++++++++++++ 5 files changed, 328 insertions(+) create mode 100644 .github/workflows/builds.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/dco.yml create mode 100644 .github/workflows/publish_to_dockerhub.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml new file mode 100644 index 00000000..9532af8f --- /dev/null +++ b/.github/workflows/builds.yml @@ -0,0 +1,70 @@ +name: Builds + +on: + pull_request: + branches: + - master + types: [opened, synchronize] + paths-ignore: + - '**/*.md' + workflow_dispatch: + +jobs: + build_cli: + name: Build CLI + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Restore Go modules from cache + uses: actions/cache@v2 + with: + path: /home/runner/go/pkg/mod + key: deps-${{ hashFiles('go.sum') }} + + - name: Update Go modules + run: make dep + + - name: Build CLI + run: make + + - name: Save binary + uses: actions/upload-artifact@v2 + with: + name: neofs-http-gw + path: bin/neofs-http-gw + + build_image: + needs: build_cli + name: Build Docker image + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Restore Go modules from cache + uses: actions/cache@v2 + with: + path: /home/runner/go/pkg/mod + key: deps-${{ hashFiles('go.sum') }} + + - name: Update Go modules + run: make dep + + - name: Build Docker image + run: make image diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..942e14dd --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '35 8 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml new file mode 100644 index 00000000..40ed8fcb --- /dev/null +++ b/.github/workflows/dco.yml @@ -0,0 +1,21 @@ +name: DCO check + +on: + pull_request: + branches: + - master + +jobs: + commits_check_job: + runs-on: ubuntu-latest + name: Commits Check + steps: + - name: Get PR Commits + id: 'get-pr-commits' + uses: tim-actions/get-pr-commits@master + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: DCO Check + uses: tim-actions/dco@master + with: + commits: ${{ steps.get-pr-commits.outputs.commits }} diff --git a/.github/workflows/publish_to_dockerhub.yml b/.github/workflows/publish_to_dockerhub.yml new file mode 100644 index 00000000..7a66b761 --- /dev/null +++ b/.github/workflows/publish_to_dockerhub.yml @@ -0,0 +1,84 @@ +name: Push images to DockerHub + +# Controls when the action will run. +on: + push: + # Publish `master` as Docker `latest` and `git_revision` images. + branches: + - master + release: + # Publish released commit as Docker `latest` and `git_revision` images. + types: + - published + + # Allows to run this workflow manually from the Actions tab. + workflow_dispatch: + inputs: + ref: + description: 'Ref to build Docker image [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]' + required: false + default: '' + push_image: + description: 'Push image to DockerHub [default: false; examples: true, false]' + required: false + default: 'false' + +# A workflow run. +jobs: + publish: + name: Publish image to DockerHub + runs-on: ubuntu-20.04 + steps: + - name: Checkout (manual run) + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 + + - name: Checkout (automatical run) + if: ${{ github.event_name != 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Restore go modules from cache + uses: actions/cache@v2 + with: + path: /home/runner/go/pkg/mod + key: deps-${{ hashFiles('go.sum') }} + + - name: Update Go modules + run: make dep + + - name: Build image + run: make image + + - name: Build image with 'latest' tag + if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} + run: make image + env: + HUB_TAG: latest + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push image to registry + if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} + run: make image-push + + - name: Push image with 'latest' tag to registry + if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} + run: make image-push + env: + HUB_TAG: latest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..42f8b70a --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,86 @@ +name: Tests + +on: + pull_request: + branches: + - master + types: [opened, synchronize] + paths-ignore: + - '**/*.md' + workflow_dispatch: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: latest + + cover: + name: Coverage + runs-on: ubuntu-20.04 + + env: + CGO_ENABLED: 1 + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.16 + + - name: Restore Go modules from cache + uses: actions/cache@v2 + with: + path: /home/runner/go/pkg/mod + key: deps-${{ hashFiles('go.sum') }} + + - name: Update Go modules + run: make dep + + - name: Test and write coverage profile + run: make cover + + - name: Upload coverage results to Codecov + uses: codecov/codecov-action@v1 + with: + fail_ci_if_error: false + path_to_write_report: ./coverage.txt + verbose: true + + tests: + name: Tests + runs-on: ubuntu-20.04 + strategy: + matrix: + go_versions: [ '1.16' ] + fail-fast: false + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: '${{ matrix.go_versions }}' + + - name: Restore Go modules from cache + uses: actions/cache@v2 + with: + path: /home/runner/go/pkg/mod + key: deps-${{ hashFiles('go.sum') }} + + - name: Update Go modules + run: make dep + + - name: Run tests + run: make test From 088cd76bc22f0f3f6f6de739a45e3fe8f9a52b09 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Fri, 21 May 2021 18:48:32 +0300 Subject: [PATCH 2/2] [#51] *: Temporarily disable some jobs of workflow Because building and publishing of docker images are not working now. Signed-off-by: Angira Kekteeva --- .github/workflows/builds.yml | 3 +++ ...lish_to_dockerhub.yml => publish_to_dockerhub.yml.disabled} | 2 ++ 2 files changed, 5 insertions(+) rename .github/workflows/{publish_to_dockerhub.yml => publish_to_dockerhub.yml.disabled} (95%) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 9532af8f..398f3d9a 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -42,11 +42,14 @@ jobs: name: neofs-http-gw path: bin/neofs-http-gw +# This job was made being skipped because building of a docker image is not working at this moment build_image: needs: build_cli name: Build Docker image runs-on: ubuntu-20.04 + if: ${{ false }} # remove this line when building of docker image will work + steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/publish_to_dockerhub.yml b/.github/workflows/publish_to_dockerhub.yml.disabled similarity index 95% rename from .github/workflows/publish_to_dockerhub.yml rename to .github/workflows/publish_to_dockerhub.yml.disabled index 7a66b761..3ce59d75 100644 --- a/.github/workflows/publish_to_dockerhub.yml +++ b/.github/workflows/publish_to_dockerhub.yml.disabled @@ -1,3 +1,5 @@ +# Jobs in this file are disabled because building of a docker image is not working +# Remove .disabled extension to enable it name: Push images to DockerHub # Controls when the action will run.