diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml deleted file mode 100644 index acc2ec94..00000000 --- a/.github/workflows/dev.yml +++ /dev/null @@ -1,389 +0,0 @@ -name: Dev Release -on: - push: - branches: - - dev - paths-ignore: - - '**.md' - pull_request: - branches: - - dev - paths-ignore: - - '**.md' - -jobs: - compile: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - uses: actions/setup-node@v1 - with: - node-version: '12.18.2' - - name: Configure AWS credentials from account - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - - name: Add GOBIN to PATH - run: | - echo "::add-path::$(go env GOPATH)/bin" - echo ::set-env name=VERSION::$(cat version.txt) - shell: bash - - - name: Install Global Dependencies - run: npm install -g yarn sass cross-env - - - name: Download Frontend Dependencies - if: steps.nodecache.outputs.cache-hit != 'true' - working-directory: ./frontend - run: yarn - - - name: Download Go mods - if: steps.golangcache.outputs.cache-hit != 'true' - run: | - go mod download - go mod verify - make test-deps - - - name: Build Frontend Statping - run: make clean compile - - - name: Upload Compiled Frontend (rice-box.go) - uses: actions/upload-artifact@v1 - with: - name: static-rice-box - path: ./source - - - name: Upload Assets to S3 - run: | - tar -czvf source.tar.gz source/ - aws s3 cp source.tar.gz s3://assets.statping.com/${{ env.GITHUB_SHA }}/ - rm -rf source.tar.gz - - test: - needs: compile - 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 - - 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.14.2' - - uses: actions/setup-node@v1 - with: - node-version: '12.18.2' - - - name: Install Global Dependencies - run: npm install -g yarn sass newman cross-env wait-on @sentry/cli - - - 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: ${{ env.GITHUB_SHA }} - run: | - make build certs - chmod +x statping - mv statping $(go env GOPATH)/bin/ - - - name: Go Tests - run: | - go get gotest.tools/gotestsum - gotestsum --no-summary=skipped --format dots -- -covermode=count -coverprofile=coverage.out -p=1 ./... - env: - VERSION: ${{ env.VERSION }} - COMMIT: ${{ env.GITHUB_SHA }} - DB_CONN: sqlite3 - STATPING_DIR: ${{ github.workspace }} - API_SECRET: demopassword123 - DISABLE_LOGS: false - ALLOW_REPORTS: true - COVERALLS: ${{ secrets.COVERALLS }} - DISCORD_URL: ${{ secrets.DISCORD_URL }} - EMAIL_HOST: ${{ secrets.EMAIL_HOST }} - EMAIL_USER: ${{ secrets.EMAIL_USER }} - EMAIL_PASS: ${{ secrets.EMAIL_PASS }} - EMAIL_OUTGOING: ${{ secrets.EMAIL_OUTGOING }} - EMAIL_SEND_TO: ${{ secrets.EMAIL_SEND_TO }} - EMAIL_PORT: ${{ secrets.EMAIL_PORT }} - MOBILE_ID: ${{ secrets.MOBILE_ID }} - MOBILE_NUMBER: ${{ secrets.MOBILE_NUMBER }} - PUSHOVER_TOKEN: ${{ secrets.PUSHOVER_TOKEN }} - PUSHOVER_API: ${{ secrets.PUSHOVER_API }} - SLACK_URL: ${{ secrets.SLACK_URL }} - TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} - TELEGRAM_CHANNEL: ${{ secrets.TELEGRAM_CHANNEL }} - TWILIO_SID: ${{ secrets.TWILIO_SID }} - TWILIO_SECRET: ${{ secrets.TWILIO_SECRET }} - TWILIO_FROM: ${{ secrets.TWILIO_FROM }} - TWILIO_TO: ${{ secrets.TWILIO_TO }} - TEST_EMAIL: ${{ secrets.TEST_EMAIL }} - GOTIFY_URL: ${{ secrets.GOTIFY_URL }} - GOTIFY_TOKEN: ${{ secrets.GOTIFY_TOKEN }} - - - name: Coveralls Testing Coverage - run: | - go get github.com/mattn/goveralls - goveralls -coverprofile=coverage.out -repotoken $COVERALLS - env: - COVERALLS: ${{ secrets.COVERALLS }} - - test-postman-sqlite: - needs: compile - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - - 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: ${{ env.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 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: compile - 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.14.2' - - - 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: ${{ env.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: compile - 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.14.2' - - - 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: ${{ env.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 - - sentry-release: - needs: test - runs-on: ubuntu-latest - steps: - - name: Checkout Statping Repo - uses: actions/checkout@v2 - - - name: Setup Sentry CLI - uses: mathrix-education/setup-sentry-cli@master - with: - version: latest - url: ${{ secrets.SENTRY_URL }} - token: ${{ secrets.SENTRY_AUTH_TOKEN }} - organization: statping - - - name: Setting ENV's - run: echo ::set-env name=VERSION::$(cat version.txt) - shell: bash - - - name: Sentry Release - run: make sentry-release - - docker-release: - needs: [test, 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 - env: - VERSION: ${{ env.VERSION }} - COMMIT: ${{ env.GITHUB_SHA }} - run: make buildx-base - - - name: Docker Build :dev - env: - VERSION: ${{ env.VERSION }} - COMMIT: ${{ env.GITHUB_SHA }} - run: make buildx-dev diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index acc1722a..a980db00 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -326,7 +326,6 @@ jobs: timeoutRequest: 30000 delayRequest: 600 - sentry-release: needs: [test, test-postman] runs-on: ubuntu-latest diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index dbbd9681..2e17da23 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -1,4 +1,4 @@ -name: Master Release +name: Master Build on: push: branches: @@ -7,52 +7,41 @@ on: - '**.md' jobs: - compile: + + frontend: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 - uses: actions/setup-go@v2 with: - go-version: '1.14.2' + go-version: 1.15.x - uses: actions/setup-node@v1 with: - node-version: '12.18.2' - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - uses: actions/checkout@v2 + node-version: 12.18.2 - - name: Add GOBIN to PATH + - name: Set Version run: | echo "::add-path::$(go env GOPATH)/bin" echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Font Awesome authentication - env: - FONTAWESOME_TOKEN: ${{ secrets.FONTAWESOME_TOKEN }} - run: | - npm config set "@fortawesome:registry" https://npm.fontawesome.com/ - npm config set "//npm.fontawesome.com/:_authToken" $FONTAWESOME_TOKEN - - name: Install Global Dependencies run: npm install -g yarn sass cross-env - name: Download Frontend Dependencies - if: steps.nodecache.outputs.cache-hit != 'true' working-directory: ./frontend run: yarn - name: Download Go mods - if: steps.golangcache.outputs.cache-hit != 'true' run: | go mod download go mod verify make test-deps - name: Build Frontend Statping + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} run: make clean compile - name: Upload Compiled Frontend (rice-box.go) @@ -61,23 +50,130 @@ jobs: name: static-rice-box path: ./source - - name: Upload Assets to S3 + - name: Configure AWS credentials for Asset uploads + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Upload Static Assets to S3 run: | tar -czvf source.tar.gz source/ - cp source.tar.gz source-${VERSION}.tar.gz - aws s3 cp source.tar.gz s3://assets.statping.com/ - aws s3 cp source-${VERSION}.tar.gz s3://assets.statping.com/ + aws s3 cp source.tar.gz s3://assets.statping.com/commit/${{ github.sha }}/ rm -rf source.tar.gz - rm -rf source-${VERSION}.tar.gz - aws s3 cp source/dist/css/ s3://assets.statping.com/css/ --recursive - aws s3 cp source/dist/js/ s3://assets.statping.com/js/ --recursive - aws s3 cp source/dist/scss/ s3://assets.statping.com/scss/ --recursive - aws s3 cp install.sh s3://assets.statping.com/ + + build: + needs: frontend + runs-on: ubuntu-latest + strategy: + matrix: + platform: [linux] + arch: [386, amd64, arm-7, arm-6, arm64] + include: + - platform: darwin + arch: amd64 + - platform: windows + arch: amd64 + + steps: + - uses: actions/checkout@v2 + + - name: Download Compiled Frontend (rice-box.go) + uses: actions/download-artifact@v1 + with: + name: static-rice-box + path: ./source + + - name: Configure AWS credentials for Asset uploads + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Add GOBIN to PATH + run: | + echo ::set-env name=VERSION::$(cat version.txt) + shell: bash + + - name: Set Linux Build Flags + if: matrix.platform != 'darwin' + run: echo ::set-env name=BUILD_FLAGS::'-extldflags -static' + shell: bash + + - name: Build ${{ matrix.platform }}/${{ matrix.arch }} + uses: crazy-max/ghaction-xgo@v1 + env: + VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} + with: + xgo_version: latest + go_version: 1.15.x + dest: build + prefix: statping + targets: ${{ matrix.platform }}/${{ matrix.arch }} + v: false + x: false + pkg: cmd + buildmode: pie + ldflags: -s -w -X main.VERSION=${{ env.VERSION }} -X main.COMMIT=${{ env.COMMIT }} ${{ env.BUILD_FLAGS }} + + - name: Compress Linux Builds + if: matrix.platform == 'linux' + run: | + cd build + mv statping-linux-${{ matrix.arch }} statping + chmod +x statping + tar -czvf statping-linux-${{ matrix.arch }}.tar.gz statping + rm -rf statping + echo ::set-env name=compressed::statping-linux-${{ matrix.arch }}.tar.gz + + - name: Compress Windows Builds + if: matrix.platform == 'windows' + run: | + cd build + mv statping-windows-4.0-${{ matrix.arch }}.exe statping.exe + chmod +x statping.exe + zip statping-windows-${{ matrix.arch }}.zip statping.exe + rm -rf statping.exe + echo ::set-env name=compressed::statping-windows-${{ matrix.arch }}.zip + + - name: Compress Darwin Builds + if: matrix.platform == 'darwin' + run: | + cd build + mv statping-darwin-10.6-${{ matrix.arch }} statping + chmod +x statping + tar -czvf statping-darwin-${{ matrix.arch }}.tar.gz statping + rm -rf statping + echo ::set-env name=compressed::statping-darwin-${{ matrix.arch }}.tar.gz + + - name: Upload Compiled Statping Binary + uses: actions/upload-artifact@v1 + with: + 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: dev-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: compile + needs: frontend runs-on: ubuntu-latest - services: postgres: image: postgres:10.8 @@ -99,13 +195,13 @@ jobs: 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.14.2' + go-version: 1.15.x - uses: actions/setup-node@v1 with: - node-version: '12.18.2' - - uses: actions/checkout@v2 + node-version: 12.18.2 - name: Install Global Dependencies run: npm install -g yarn sass newman cross-env wait-on @sentry/cli @@ -126,6 +222,7 @@ jobs: - name: Install Statping env: VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} run: | make build certs chmod +x statping @@ -137,6 +234,7 @@ jobs: gotestsum --no-summary=skipped --format dots -- -covermode=count -coverprofile=coverage.out -p=1 ./... env: VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} DB_CONN: sqlite3 STATPING_DIR: ${{ github.workspace }} API_SECRET: demopassword123 @@ -172,111 +270,13 @@ jobs: env: COVERALLS: ${{ secrets.COVERALLS }} - test-postman-sqlite: - needs: compile + + test-postman: + needs: [frontend, build] runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - - 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 }} - 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 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: compile - 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.14.2' - - - 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 }} - 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: compile - runs-on: ubuntu-latest - + strategy: + matrix: + platform: [postman_env_sqlite.json, postman_env_postgres.json, postman_env_mysql.json] services: postgres: image: postgres:10.8 @@ -287,196 +287,47 @@ jobs: ports: - 5432:5432 options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 - + 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.14.2' - - 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) + - name: Download Statping uses: actions/download-artifact@v1 with: - name: static-rice-box - path: ./source + name: statping-linux-amd64 + path: ./build - name: Install Statping env: VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} run: | - make build - chmod +x statping - mv statping $(go env GOPATH)/bin/ + cd build && tar -xvf statping-linux-amd64.tar.gz + mv statping ../ - name: Run Statping run: | - API_SECRET=demosecret123 statping --port=8585 > /dev/null & + API_SECRET=demosecret123 ./statping --port=8585 > /dev/null & sleep 5 - - name: Postman Postgres Tests + - name: Postman Tests uses: matt-ball/newman-action@master with: apiKey: ${{ secrets.POSTMAN_API }} collection: ./dev/postman.json - environment: ./dev/postman_env_postgres.json + environment: ./dev/${{ matrix.platform }} timeoutRequest: 30000 delayRequest: 600 - build-binaries: - needs: compile - runs-on: ubuntu-latest - steps: - - uses: actions/setup-go@v2 - with: - go-version: '1.14.2' - - uses: actions/checkout@v2 - - - name: Install cross compiling libraries - run: | - sudo apt-get update - sudo apt-get install -y automake autogen build-essential ca-certificates libsqlite3-dev \ - gcc-5-arm-linux-gnueabi g++-5-arm-linux-gnueabi libc6-dev-armel-cross linux-headers-generic \ - gcc-5-arm-linux-gnueabihf g++-5-arm-linux-gnueabihf libc6-dev-armhf-cross \ - gcc-5-aarch64-linux-gnu g++-5-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-5-mips-linux-gnu g++-5-mips-linux-gnu libc6-dev-mips-cross \ - gcc-5-mipsel-linux-gnu g++-5-mipsel-linux-gnu libc6-dev-mipsel-cross \ - gcc-5-mips64-linux-gnuabi64 g++-5-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ - gcc-5-mips64el-linux-gnuabi64 g++-5-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ - gcc-5-multilib g++-5-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ - gcc-6-arm-linux-gnueabi g++-6-arm-linux-gnueabi libc6-dev-armel-cross \ - gcc-6-arm-linux-gnueabihf g++-6-arm-linux-gnueabihf libc6-dev-armhf-cross \ - gcc-6-aarch64-linux-gnu g++-6-aarch64-linux-gnu libc6-dev-arm64-cross \ - gcc-6-mips-linux-gnu g++-6-mips-linux-gnu libc6-dev-mips-cross \ - gcc-6-mipsel-linux-gnu g++-6-mipsel-linux-gnu libc6-dev-mipsel-cross \ - gcc-6-mips64-linux-gnuabi64 g++-6-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ - gcc-6-mips64el-linux-gnuabi64 g++-6-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ - gcc-6-multilib gcc-7-multilib g++-6-multilib gcc-mingw-w64 g++-mingw-w64 clang llvm-dev \ - libtool libxml2-dev uuid-dev libssl-dev swig openjdk-8-jdk pkg-config patch \ - make xz-utils cpio wget zip unzip p7zip git mercurial bzr texinfo help2man cmake --no-install-recommends - sudo ln -s /usr/include/asm-generic/ /usr/include/asm - - - 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 Go mods - run: | - make test-deps - - - name: Download Compiled Frontend (rice-box.go) - uses: actions/download-artifact@v1 - with: - name: static-rice-box - path: ./source - - - name: Build Binaries - env: - VERSION: ${{ env.VERSION }} - COMMIT: $GITHUB_SHA - MJML_APP: ${{ secrets.MJML_APP }} - MJML_PRIVATE: ${{ secrets.MJML_PRIVATE }} - run: make build-folders build-linux build-linux-arm build-darwin build-win compress-folders - - - name: Upload Builds - uses: actions/upload-artifact@v1 - with: - name: builds - path: ./build - - upload-release: - needs: [test, test-postman-sqlite, test-postman-mysql, test-postman-postgres, build-binaries] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - 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 Builds - uses: actions/download-artifact@v1 - with: - name: builds - path: ./builds - - - 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: false - prerelease: true - files: | - builds/statping-linux-386.tar.gz - builds/statping-linux-amd64.tar.gz - builds/statping-linux-arm6.tar.gz - builds/statping-linux-arm7.tar.gz - builds/statping-linux-arm64.tar.gz - builds/statping-darwin-amd64.tar.gz - builds/statping-darwin-386.tar.gz - builds/statping-windows-386.zip - builds/statping-windows-amd64.zip - builds/statping-windows-arm.zip - - docker-release: - needs: upload-release - 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 - env: - VERSION: ${{ env.VERSION }} - COMMIT: ${{ github.sha }} - run: make buildx-base - - - name: Docker Build :lastest - env: - VERSION: ${{ env.VERSION }} - COMMIT: ${{ github.sha }} - run: make buildx-latest - sentry-release: - needs: upload-release + needs: [test, test-postman] runs-on: ubuntu-latest steps: - name: Checkout Statping Repo @@ -498,7 +349,7 @@ jobs: run: make sentry-release homebrew-release: - needs: upload-release + needs: [frontend, build, test, test-postman] runs-on: ubuntu-latest steps: - name: Checkout Statping Repo @@ -515,7 +366,7 @@ jobs: run: make publish-homebrew slack-update: - needs: upload-release + needs: [frontend, build, test, test-postman] runs-on: ubuntu-latest steps: - name: Checkout Statping Repo diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index d5a96c5e..319a230b 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,13 +25,6 @@ jobs: echo ::set-env name=VERSION::$(cat version.txt) shell: bash - - name: Font Awesome authentication - env: - FONTAWESOME_TOKEN: ${{ secrets.FONTAWESOME_TOKEN }} - run: | - npm config set "@fortawesome:registry" https://npm.fontawesome.com/ - npm config set "//npm.fontawesome.com/:_authToken" $FONTAWESOME_TOKEN - - name: Install Global Dependencies run: npm install -g yarn sass cross-env @@ -83,10 +76,10 @@ jobs: steps: - uses: actions/setup-go@v2 with: - go-version: '1.14.2' + go-version: 1.15.x - uses: actions/setup-node@v1 with: - node-version: '12.18.2' + node-version: 12.18.2 - uses: actions/checkout@v2 - name: Install Global Dependencies @@ -120,6 +113,7 @@ jobs: SASS=`which sass` gotestsum --no-summary=skipped --format dots -- -covermode=count -coverprofile=coverage.out -p=1 ./... env: VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} DB_CONN: sqlite3 STATPING_DIR: ${{ github.workspace }} API_SECRET: demopassword123 @@ -152,6 +146,7 @@ jobs: - name: Install Statping env: VERSION: ${{ env.VERSION }} + COMMIT: ${{ github.sha }} run: | make build chmod +x statping diff --git a/utils/log.go b/utils/log.go index 246cb0e2..9f0b186e 100644 --- a/utils/log.go +++ b/utils/log.go @@ -60,9 +60,16 @@ func SentryErr(err error) { sentry.CaptureException(err) } +func sentryTags() map[string]string { + val := make(map[string]string) + val["database"] = Params.GetString("DB_CONN") + return val +} + func SentryLogEntry(entry *Logger.Entry) { e := sentry.NewEvent() e.Message = entry.Message + e.Tags = sentryTags() e.Release = Version e.Contexts = entry.Data sentry.CaptureEvent(e)