mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
Update update-dependencies.yml
This commit is contained in:
parent
d065a50231
commit
b32e178735
1 changed files with 41 additions and 38 deletions
79
.github/workflows/update-dependencies.yml
vendored
79
.github/workflows/update-dependencies.yml
vendored
|
@ -2,21 +2,21 @@ name: Update Go Dependencies
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * 1' # Run weekly on Monday at 00:00 UTC
|
- cron: '0 0 * * 1' # Запуск каждую неделю в понедельник в 00:00 UTC
|
||||||
workflow_dispatch: # Allow manual triggering
|
workflow_dispatch: # Возможность ручного запуска
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write # Explicitly set permissions
|
contents: write # Явное указание разрешений
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update:
|
update:
|
||||||
runs-on: ubuntu-latest # Use latest Ubuntu for better security
|
runs-on: ubuntu-20.04 # Используем свежую Ubuntu
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch all history for better change detection
|
fetch-depth: 0 # Загружаем всю историю
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
|
@ -24,7 +24,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
check-latest: true
|
check-latest: true
|
||||||
cache: true # Enable Go module caching
|
cache: true # Включаем кэширование модулей
|
||||||
|
|
||||||
- name: Clean Go module cache
|
- name: Clean Go module cache
|
||||||
run: |
|
run: |
|
||||||
|
@ -35,58 +35,61 @@ jobs:
|
||||||
- name: Update dependencies
|
- name: Update dependencies
|
||||||
id: update
|
id: update
|
||||||
run: |
|
run: |
|
||||||
# Create error log file
|
set -e # Прерываем выполнение при ошибках
|
||||||
|
echo "Updating Go dependencies..."
|
||||||
|
|
||||||
touch update_errors.log
|
touch update_errors.log
|
||||||
|
|
||||||
# Update dependencies with error handling
|
|
||||||
{
|
{
|
||||||
# List current versions
|
# Сохраняем текущие версии
|
||||||
echo "Current versions:" > dependency_changes.txt
|
echo "Current versions:" > dependency_changes.txt
|
||||||
go list -m all >> 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 | \
|
go get -u ./...
|
||||||
grep -v 'gvisor.dev/gvisor')
|
|
||||||
|
# Приводим зависимости в порядок
|
||||||
# Tidy and verify modules
|
|
||||||
go mod tidy
|
go mod tidy
|
||||||
go mod verify
|
go mod verify
|
||||||
|
|
||||||
# List updated versions
|
# Записываем обновленные версии
|
||||||
echo -e "\nUpdated versions:" >> dependency_changes.txt
|
echo -e "\nUpdated versions:" >> dependency_changes.txt
|
||||||
go list -m all >> dependency_changes.txt
|
go list -m all >> dependency_changes.txt
|
||||||
|
|
||||||
} 2>update_errors.log || {
|
} 2>update_errors.log || {
|
||||||
echo "::error::Failed to update dependencies"
|
echo "::error::Dependency update failed"
|
||||||
cat update_errors.log
|
cat update_errors.log
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Validate build
|
- name: Validate build & run tests
|
||||||
run: |
|
run: |
|
||||||
# Verify the project still builds
|
set -e
|
||||||
go build ./... || {
|
|
||||||
echo "::error::Build validation failed after dependency updates"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Run tests if they exist
|
# Проверяем, что код компилируется
|
||||||
if [ -n "$(go list ./... | grep -v vendor)" ]; then
|
echo "Validating build..."
|
||||||
go test ./... -race || {
|
go build ./...
|
||||||
echo "::error::Tests failed after dependency updates"
|
|
||||||
exit 1
|
# Проверяем статический анализ кода
|
||||||
}
|
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
|
fi
|
||||||
|
|
||||||
- name: Check for changes
|
- name: Check for changes
|
||||||
id: check
|
id: check
|
||||||
run: |
|
run: |
|
||||||
if ! git diff --exit-code go.mod go.sum; then
|
if git diff --quiet go.mod go.sum; then
|
||||||
echo "changes=true" >> $GITHUB_ENV
|
echo "No dependency changes detected."
|
||||||
echo "Changes detected in dependencies"
|
|
||||||
else
|
|
||||||
echo "changes=false" >> $GITHUB_ENV
|
echo "changes=false" >> $GITHUB_ENV
|
||||||
echo "No dependency changes needed"
|
else
|
||||||
|
echo "Dependency changes detected."
|
||||||
|
echo "changes=true" >> $GITHUB_ENV
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
|
|
Loading…
Reference in a new issue