diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index be99e737..3a4091c0 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -424,6 +424,40 @@ jobs: timeoutRequest: 30000 delayRequest: 600 + docker-release: + needs: [test, build, test-postman-sqlite, test-postman-mysql, test-postman-postgres] + runs-on: ubuntu-latest + steps: + - name: Checkout Statping Repo + uses: actions/checkout@v2 + + - name: Setting ENV's + run: echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Docker Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Cache Docker layers + uses: actions/cache@v2 + id: buildx-docker-master + with: + path: /tmp/.buildx-cache + key: buildx-docker-master + restore-keys: | + buildx-docker-master + - name: Docker Build :base + run: make buildx-base + + - name: Docker Build :dev + run: make buildx-dev + sentry-release: needs: [test, test-postman-sqlite, test-postman-postgres, test-postman-mysql] runs-on: ubuntu-latest diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index ebbc7b48..116ec4b3 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -155,6 +155,22 @@ jobs: name: statping-${{ matrix.platform }}-${{ matrix.arch }} path: ./build + - name: Upload Releases + id: upload-assets + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VERSION: ${{ env.VERSION }} + with: + tag_name: v${{ env.VERSION }} + draft: true + prerelease: true + files: build/${{ env.compressed }} + + - name: Upload Compiled Binaries to S3 + run: | + aws s3 cp build/${{ env.compressed }} s3://assets.statping.com/commit/${{ github.sha }}/ + test: needs: frontend runs-on: ubuntu-latest @@ -254,40 +270,196 @@ jobs: env: COVERALLS: ${{ secrets.COVERALLS }} - release: - needs: [build, test] + test-postman-sqlite: + needs: frontend runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x - - name: Get Version + - name: Setting ENV's run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/12.18.2/x64/bin" echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Download Compiled Binaries + - name: Download Compiled Frontend (rice-box.go) uses: actions/download-artifact@v1 with: - path: ./build + name: static-rice-box + path: ./source - - name: Upload Releases - id: upload-assets - uses: softprops/action-gh-release@v1 + - name: Install Statping env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ env.VERSION }} - with: - tag_name: v${{ env.VERSION }} - draft: false - prerelease: true - files: build/${{ env.compressed }} - - - name: Upload Compiled Binaries to S3 + COMMIT: ${{ github.sha }} run: | - aws s3 cp build/*.* s3://assets.statping.com/commit/${{ github.sha }}/ + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + - name: Postman SQLite Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_sqlite.json + timeoutRequest: 30000 + delayRequest: 600 + + test-postman-mysql: + needs: frontend + runs-on: ubuntu-latest + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: password123 + MYSQL_DATABASE: statping + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/12.18.2/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} + MJML_APP: ${{ secrets.MJML_APP }} + MJML_PRIVATE: ${{ secrets.MJML_PRIVATE }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + - name: Postman MySQL Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_mysql.json + timeoutRequest: 30000 + delayRequest: 600 + + test-postman-postgres: + needs: frontend + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:10.8 + env: + POSTGRES_USER: root + POSTGRES_PASSWORD: password123 + POSTGRES_DB: statping + ports: + - 5432:5432 + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.15.x + + - name: Setting ENV's + run: | + echo "::add-path::$(go env GOPATH)/bin" + echo "::add-path::/opt/hostedtoolcache/node/12.18.2/x64/bin" + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Install Statping + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} + run: | + make build + chmod +x statping + mv statping $(go env GOPATH)/bin/ + - name: Run Statping + run: | + API_SECRET=demosecret123 statping --port=8585 > /dev/null & + sleep 5 + - name: Postman Postgres Tests + uses: matt-ball/newman-action@master + with: + apiKey: ${{ secrets.POSTMAN_API }} + collection: ./dev/postman.json + environment: ./dev/postman_env_postgres.json + timeoutRequest: 30000 + delayRequest: 600 + + docker-release: + needs: [build, test, test-postman-sqlite, test-postman-postgres, test-postman-mysql] + runs-on: ubuntu-latest + steps: + - name: Checkout Statping Repo + uses: actions/checkout@v2 + + - name: Setting ENV's + run: echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Set up Docker Buildx + uses: crazy-max/ghaction-docker-buildx@v3 + + - name: Docker Login + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + + - name: Cache Docker layers + uses: actions/cache@v2 + id: buildx-docker + with: + path: /tmp/.buildx-cache + key: buildx-docker + restore-keys: | + buildx-docker + - name: Docker Build :base + run: make buildx-base + + - name: Docker Build :lastest + run: make buildx-latest sentry-release: - needs: release + needs: [test, test-postman-sqlite, test-postman-postgres, test-postman-mysql] runs-on: ubuntu-latest steps: - name: Checkout Statping Repo