chore: add makefile, ci #1
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 Pipeline | |
| on: | |
| push: | |
| branches: [ master, main, develop ] | |
| pull_request: | |
| branches: [ master, main, develop ] | |
| release: | |
| types: [ published ] | |
| env: | |
| RUBY_VERSION: '2.6.0' | |
| jobs: | |
| test: | |
| name: Test Suite | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| ruby-version: ['2.6.0', '2.7.0', '3.0.0', '3.1.0', '3.2.0'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ matrix.ruby-version }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| gem install bundler | |
| bundle install --jobs 4 --retry 3 | |
| - name: Run unit tests | |
| run: make test-unit | |
| - name: Run integration tests | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') | |
| env: | |
| STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }} | |
| STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }} | |
| STREAM_APP_ID: ${{ secrets.STREAM_APP_ID }} | |
| run: make test-integration | |
| - name: Run code formatting check | |
| run: make format-check | |
| - name: Run linting | |
| run: make lint | |
| - name: Run security audit | |
| run: make security | |
| continue-on-error: true | |
| integration-tests: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' || (github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ env.RUBY_VERSION }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| gem install bundler | |
| bundle install --jobs 4 --retry 3 | |
| - name: Run integration tests | |
| env: | |
| STREAM_API_KEY: ${{ secrets.STREAM_API_KEY }} | |
| STREAM_API_SECRET: ${{ secrets.STREAM_API_SECRET }} | |
| STREAM_APP_ID: ${{ secrets.STREAM_APP_ID }} | |
| run: make test-integration | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: [test, integration-tests] | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ env.RUBY_VERSION }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| gem install bundler | |
| bundle install --jobs 4 --retry 3 | |
| - name: Check for major release | |
| id: check-major | |
| run: | | |
| if git log --oneline -1 | grep -q "major"; then | |
| echo "release_type=major" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check for minor release | |
| id: check-minor | |
| run: | | |
| if git log --oneline -1 | grep -q "minor"; then | |
| echo "release_type=minor" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Check for patch release | |
| id: check-patch | |
| run: | | |
| if git log --oneline -1 | grep -q "patch"; then | |
| echo "release_type=patch" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Determine release type | |
| id: release-type | |
| run: | | |
| if [ "${{ steps.check-major.outputs.should_release }}" = "true" ]; then | |
| echo "release_type=major" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| elif [ "${{ steps.check-minor.outputs.should_release }}" = "true" ]; then | |
| echo "release_type=minor" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| elif [ "${{ steps.check-patch.outputs.should_release }}" = "true" ]; then | |
| echo "release_type=patch" >> $GITHUB_OUTPUT | |
| echo "should_release=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "should_release=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Release gem | |
| if: steps.release-type.outputs.should_release == 'true' | |
| env: | |
| RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| run: | | |
| echo "Releasing ${{ steps.release-type.outputs.release_type }} version..." | |
| make release-${{ steps.release-type.outputs.release_type }} | |
| - name: Create GitHub Release | |
| if: steps.release-type.outputs.should_release == 'true' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ steps.release-type.outputs.release_type }} | |
| release_name: Release ${{ steps.release-type.outputs.release_type }} | |
| body: | | |
| This is an automated ${{ steps.release-type.outputs.release_type }} release. | |
| Changes in this release: | |
| - See commit history for details | |
| draft: false | |
| prerelease: false | |
| security-scan: | |
| name: Security Scan | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: ${{ env.RUBY_VERSION }} | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| gem install bundler | |
| bundle install --jobs 4 --retry 3 | |
| - name: Run security audit | |
| run: make security | |
| - name: Run CodeQL Analysis | |
| uses: github/codeql-action/analyze@v2 | |
| with: | |
| languages: ruby |