diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 2f6826d8..9b9a7aa9 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -2,21 +2,21 @@ name: Update Go Dependencies on: schedule: - - cron: '0 0 * * 1' # Run weekly on Monday at 00:00 UTC - workflow_dispatch: # Allow manual triggering - + - cron: '0 0 * * 1' # Запуск каждую неделю в понедельник в 00:00 UTC + workflow_dispatch: # Возможность ручного запуска + permissions: - contents: write # Explicitly set permissions + contents: write # Явное указание разрешений jobs: update: - runs-on: ubuntu-latest # Use latest Ubuntu for better security + runs-on: ubuntu-20.04 # Используем свежую Ubuntu steps: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 # Fetch all history for better change detection + fetch-depth: 0 # Загружаем всю историю token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Go @@ -24,7 +24,7 @@ jobs: with: go-version-file: go.mod check-latest: true - cache: true # Enable Go module caching + cache: true # Включаем кэширование модулей - name: Clean Go module cache run: | @@ -35,58 +35,61 @@ jobs: - name: Update dependencies id: update run: | - # Create error log file + set -e # Прерываем выполнение при ошибках + echo "Updating Go dependencies..." + touch update_errors.log - - # Update dependencies with error handling + { - # List current versions + # Сохраняем текущие версии echo "Current versions:" > dependency_changes.txt go list -m all >> dependency_changes.txt - - # Update dependencies, excluding specific packages - go get -u $(go list -f '{{if not (or .Main .Indirect)}}{{.Path}}{{end}}' -m all | \ - grep -v 'gvisor.dev/gvisor') - - # Tidy and verify modules + + # Обновляем только объявленные зависимости + go get -u ./... + + # Приводим зависимости в порядок go mod tidy go mod verify - - # List updated versions + + # Записываем обновленные версии echo -e "\nUpdated versions:" >> dependency_changes.txt go list -m all >> dependency_changes.txt - } 2>update_errors.log || { - echo "::error::Failed to update dependencies" + echo "::error::Dependency update failed" cat update_errors.log exit 1 } - - name: Validate build + - name: Validate build & run tests run: | - # Verify the project still builds - go build ./... || { - echo "::error::Build validation failed after dependency updates" - exit 1 - } + set -e - # Run tests if they exist - if [ -n "$(go list ./... | grep -v vendor)" ]; then - go test ./... -race || { - echo "::error::Tests failed after dependency updates" - exit 1 - } + # Проверяем, что код компилируется + echo "Validating build..." + go build ./... + + # Проверяем статический анализ кода + echo "Running go vet..." + go vet ./... + + # Запускаем тесты, если они есть + if go list ./... | grep -qv vendor; then + echo "Running tests..." + go test ./... -race + else + echo "No test files found, skipping tests." fi - name: Check for changes id: check run: | - if ! git diff --exit-code go.mod go.sum; then - echo "changes=true" >> $GITHUB_ENV - echo "Changes detected in dependencies" - else + if git diff --quiet go.mod go.sum; then + echo "No dependency changes detected." echo "changes=false" >> $GITHUB_ENV - echo "No dependency changes needed" + else + echo "Dependency changes detected." + echo "changes=true" >> $GITHUB_ENV fi - name: Commit and push changes