github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/.github/workflows/dm_upstream_switch.yaml (about)

     1  name: Upstream Database Switch
     2  
     3  on:
     4    schedule:
     5      - cron: '0 17-23 * * *' # run at minute 0 every hour from 01:00 ~ 07:00 UTC+8
     6    workflow_dispatch:
     7      inputs:
     8        pr:
     9          description: 'Which PR do you want to trigger'
    10          required: true
    11          default: ''
    12  
    13  jobs:
    14    upstream-database-switch:
    15      name: upstream-database-switch
    16      runs-on: ubuntu-20.04
    17  
    18      steps:
    19        - name: Set up Go env
    20          uses: actions/setup-go@v3
    21          with:
    22            go-version: '1.21'
    23  
    24        - name: Check out code
    25          uses: actions/checkout@v2
    26  
    27        - name: Check out code by workflow dispatch
    28          if: ${{ github.event.inputs.pr != '' }}
    29          uses: actions/checkout@v2
    30          with:
    31            ref: refs/pull/${{ github.event.inputs.pr }}/head
    32  
    33        - name: Cache go modules
    34          uses: actions/cache@v2
    35          with:
    36            path: ~/go/pkg/mod
    37            key: ${{ runner.os }}-ticdc-${{ hashFiles('go.sum') }}
    38  
    39        - name: Cache Tools
    40          id: cache-tools
    41          uses: actions/cache@v2
    42          with:
    43            path: tools/bin
    44            key: ${{ runner.os }}-ticdc-tools-${{ hashFiles('tools/check/go.sum') }}
    45  
    46        - name: Build DM binary
    47          run: make dm_integration_test_build
    48  
    49        - name: Setup containers
    50          run: |
    51            docker-compose -f ./dm/tests/upstream_switch/docker-compose.yml up -d
    52  
    53        - name: Run test cases
    54          run: |
    55            bash ./dm/tests/upstream_switch/case.sh
    56  
    57        - name: Copy logs to hack permission
    58          if: ${{ always() }}
    59          run: |
    60            mkdir ./logs
    61            sudo cp -r -L /tmp/dm_test/upstream_switch/master/log ./logs/master
    62            sudo cp -r -L /tmp/dm_test/upstream_switch/worker1/log ./logs/worker1
    63            sudo cp -r -L /tmp/dm_test/upstream_switch/worker2/log ./logs/worker2
    64            sudo chown -R runner ./logs
    65  
    66        # Update logs as artifact seems not stable, so we set `continue-on-error: true` here.
    67        - name: Upload logs
    68          continue-on-error: true
    69          uses: actions/upload-artifact@v2
    70          if: ${{ always() }}
    71          with:
    72            name: upstream-switch-logs
    73            path: |
    74              ./logs
    75  
    76        # send Slack notify if failed.
    77        # NOTE: With the exception of `GITHUB_TOKEN`, secrets are not passed to the runner when a workflow is triggered from a forked repository.
    78        - name: Slack notification
    79          if: ${{ failure() }}
    80          env:
    81            SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFY }}
    82          uses: Ilshidur/action-slack@2.1.0
    83          with:
    84            args: "upstream-switch job failed, see https://github.com/pingcap/tiflow/actions/runs/{{ GITHUB_RUN_ID }}"