use interface for dump service #148
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI/CD | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ["v*.*.*"] | |
| pull_request: | |
| types: [opened, reopened, synchronize] | |
| jobs: | |
| format-build-test: | |
| strategy: | |
| matrix: | |
| go-version: ['1.21.x', '1.22.x'] | |
| platform: [ubuntu-latest, macos-latest, windows-latest] | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - if: matrix.platform == 'ubuntu-latest' | |
| run: if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then exit 1; fi | |
| - run: go build -v ./... | |
| - run: make test | |
| docker-build-push: | |
| if: github.event_name != 'pull_request' | |
| needs: format-build-test | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
| - uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 | |
| id: meta | |
| with: | |
| images: | | |
| ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=ref,event=branch | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| type=sha | |
| - uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 | |
| with: | |
| context: . | |
| push: true | |
| file: Dockerfile.buildx | |
| platforms: linux/amd64,linux/arm64,linux/arm | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| release-zips: | |
| if: github.event_name != 'pull_request' | |
| needs: format-build-test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
| with: | |
| go-version: '1.21.x' | |
| - run: CGO_ENABLED=0 make release | |
| - uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 | |
| with: | |
| name: release-zips | |
| path: "*.zip" | |
| mysql-test: | |
| runs-on: 'ubuntu-latest' | |
| needs: format-build-test | |
| services: | |
| mysql: | |
| image: mysql:8.0 | |
| env: | |
| MYSQL_RANDOM_ROOT_PASSWORD: yes | |
| MYSQL_DATABASE: testdb | |
| MYSQL_USER: testuser | |
| MYSQL_PASSWORD: testpw | |
| ports: | |
| - 3800:3306 | |
| options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3 | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| MYSQL_PWD: testpw | |
| PORT: 3800 | |
| steps: | |
| - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | |
| with: | |
| go-version: '1.21.x' | |
| - name: verify mysql | |
| run: | | |
| while ! mysqladmin ping --host=localhost --port=$PORT --protocol=TCP --silent; do | |
| sleep 1 | |
| done | |
| - name: mysql schema | |
| run: | | |
| mysql --version | |
| mysql --user=testuser --host=localhost --port=$PORT --protocol=TCP testdb < ./storage/mysql/schema.sql | |
| - name: set test dsn | |
| run: echo "NANOMDM_MYSQL_STORAGE_TEST_DSN=testuser:testpw@tcp(localhost:$PORT)/testdb" >> $GITHUB_ENV | |
| - run: go test -v ./storage/mysql |