From cd5c81e107b13a044e3e6e49560e66e875f2a297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 23 Sep 2024 14:41:23 +0300 Subject: [PATCH 1/2] Optimize GH workflows. --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/build_and_test_macos.yml | 48 ++++++++++++++++++++++ .github/workflows/create_release.yml | 6 +-- .github/workflows/docker-keygenerator.yaml | 4 +- .github/workflows/golangci-lint.yml | 1 + 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build_and_test_macos.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index d552db889c7..efb1c939339 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - runs-on: [ubuntu-latest, macos-13, macos-13-xlarge] + runs-on: [ubuntu-latest] runs-on: ${{ matrix.runs-on }} name: Build steps: diff --git a/.github/workflows/build_and_test_macos.yml b/.github/workflows/build_and_test_macos.yml new file mode 100644 index 00000000000..114a3bcd2b8 --- /dev/null +++ b/.github/workflows/build_and_test_macos.yml @@ -0,0 +1,48 @@ +name: Build and smoke test (MacOS) + +on: + pull_request: + branches: [master] + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + runs-on: [macos-latest] + runs-on: ${{ matrix.runs-on }} + name: Build + steps: + - name: Set up Go 1.20.7 + uses: actions/setup-go@v3 + with: + go-version: 1.20.7 + id: go + + - name: Check out code into the Go module directory + uses: actions/checkout@v3 + + - 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: | + cd ${GITHUB_WORKSPACE}/cmd/node && go build . + cd ${GITHUB_WORKSPACE}/cmd/seednode && go build . + cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build . + cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build . + cd ${GITHUB_WORKSPACE}/cmd/termui && go build . + + # On GitHub, we only run the short tests, and we only run them for some OS/ARCH combinations. + - name: Run tests + run: | + GOOS=$(go env GOOS) + + if [[ "$GOOS" == darwin ]]; then + go test -short -v ./... + fi diff --git a/.github/workflows/create_release.yml b/.github/workflows/create_release.yml index fe74d301325..bac2bab26b7 100644 --- a/.github/workflows/create_release.yml +++ b/.github/workflows/create_release.yml @@ -15,7 +15,7 @@ jobs: build: strategy: matrix: - runs-on: [ubuntu-latest, macos-13, macos-13-xlarge] + runs-on: [ubuntu-latest] runs-on: ${{ matrix.runs-on }} name: Build steps: @@ -129,7 +129,7 @@ jobs: zip -r -j ${ARCHIVE} ${BUILD_DIR} - name: Save artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.ARCHIVE }} path: ${{ env.ARCHIVE }} @@ -145,7 +145,7 @@ jobs: # https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts # A directory for each artifact is created using its name - name: Download all workflow run artifacts - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: path: assets diff --git a/.github/workflows/docker-keygenerator.yaml b/.github/workflows/docker-keygenerator.yaml index 5e4d9d44a32..c3cca7fc279 100644 --- a/.github/workflows/docker-keygenerator.yaml +++ b/.github/workflows/docker-keygenerator.yaml @@ -2,7 +2,6 @@ name: Build & push keygenerator docker image on: workflow_dispatch: - pull_request: jobs: build-docker-image: @@ -19,7 +18,6 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log into Docker Hub - if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -32,5 +30,5 @@ jobs: context: . file: ./docker/keygenerator/Dockerfile platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + push: true tags: multiversx/chain-keygenerator:latest diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 611fadc3d08..1cc46af26c8 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -5,6 +5,7 @@ on: - master pull_request: branches: [ master, feat/*, rc/* ] + workflow_dispatch: permissions: contents: read From 75156ecd26c8eafc977804ffe34bcf57e0cc0f6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20B=C4=83ncioiu?= Date: Mon, 23 Sep 2024 14:56:43 +0300 Subject: [PATCH 2/2] Simplification. --- .github/workflows/build_and_test.yml | 2 +- .github/workflows/build_and_test_macos.yml | 48 ---------------------- 2 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 .github/workflows/build_and_test_macos.yml diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index efb1c939339..8f8985811cc 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - runs-on: [ubuntu-latest] + runs-on: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.runs-on }} name: Build steps: diff --git a/.github/workflows/build_and_test_macos.yml b/.github/workflows/build_and_test_macos.yml deleted file mode 100644 index 114a3bcd2b8..00000000000 --- a/.github/workflows/build_and_test_macos.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and smoke test (MacOS) - -on: - pull_request: - branches: [master] - workflow_dispatch: - -jobs: - build: - strategy: - matrix: - runs-on: [macos-latest] - runs-on: ${{ matrix.runs-on }} - name: Build - steps: - - name: Set up Go 1.20.7 - uses: actions/setup-go@v3 - with: - go-version: 1.20.7 - id: go - - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - 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: | - cd ${GITHUB_WORKSPACE}/cmd/node && go build . - cd ${GITHUB_WORKSPACE}/cmd/seednode && go build . - cd ${GITHUB_WORKSPACE}/cmd/keygenerator && go build . - cd ${GITHUB_WORKSPACE}/cmd/logviewer && go build . - cd ${GITHUB_WORKSPACE}/cmd/termui && go build . - - # On GitHub, we only run the short tests, and we only run them for some OS/ARCH combinations. - - name: Run tests - run: | - GOOS=$(go env GOOS) - - if [[ "$GOOS" == darwin ]]; then - go test -short -v ./... - fi