Skip to content

add

add #20

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: golangci-lint
# Controls when the workflow will run
on:
pull_request:
paths:
- tencentcloud/**
- .github/**
- .golangci.yml
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
golangci-lint:
# The type of runner that the job will run on
runs-on: macos-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-go@v3
with:
go-version-file: .go-version
#go-version: '1.21'
cache: false
- name: Get root path
id: getRootPath
run: |
echo "::set-output path=$(pwd)"
shell: bash
- name: Get list of changed directories
id: getDiffDir
run: |
echo "::set-output name=dirs::$(git diff --name-only origin/master | grep '^tencentcloud/.*\.go$' | xargs -n 1 dirname | sort -u | sed 's|^tencentcloud/||' | xargs)"
shell: bash
- name: Check for changed Go directories
id: checkDiffDir
run: |
if [ -z "${{ steps.getDiffDir.outputs.dirs }}" ]; then
echo "No Go directories changed."
exit 0
fi
- name: Print changed directories
id: showDiffDir
run: |
echo "Changed Go directories: ${{ steps.getDiffDir.outputs.dirs }}"
# Runs a set of commands using the runners shell
- name: golangci-lint
working-directory: ./tencentcloud
run: |
set -e
IFS=' ' read -r -a dirs <<< "${{ steps.getDiffFile.outputs.dirs }}"
for dir in "${dirs[@]}"; do
echo $(dir) || exit 1
cd $dir || exit 1
echo $(pwd) || exit 1
golangci-lint run --new-from-rev=origin/master -v || echo 'golangci-lint failed'
cd - || exit 1
done
shell: bash