You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2021/03/22 16:16:44 UTC
[trafficcontrol] branch master updated: A PR check to ensure
migration file added is the latest (#5652)
This is an automated email from the ASF dual-hosted git repository.
zrhoffman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 01b0499 A PR check to ensure migration file added is the latest (#5652)
01b0499 is described below
commit 01b0499f9986d2a9f7958a49248e7dd4c55fb34e
Author: Rima Shah <22...@users.noreply.github.com>
AuthorDate: Mon Mar 22 10:16:31 2021 -0600
A PR check to ensure migration file added is the latest (#5652)
* Added check to ensure added migration file is latest in time wrt other files in dir
* Update CHANGELOG.md
* Addressed feedback comment
* Updated based on review comments-1
* Removed print statements.
* Remove dir change
* Added git package
* Updated based on review comments.
* Running entrypoint on ubuntu instead of alpine.
* Updated push and pull request paths in workflows.
* Updated logic for latest file and time
* Added fetch-depth in workflow
---
.github/actions/todb-tests/Dockerfile | 2 +-
.github/actions/todb-tests/entrypoint.sh | 17 +++++++++++++++++
.github/workflows/traffic.ops.database.yml | 10 ++++++++--
CHANGELOG.md | 1 +
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/.github/actions/todb-tests/Dockerfile b/.github/actions/todb-tests/Dockerfile
index 91f49c4..4425994 100644
--- a/.github/actions/todb-tests/Dockerfile
+++ b/.github/actions/todb-tests/Dockerfile
@@ -18,7 +18,7 @@
# alpine:3.13
FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930
-RUN apk add --no-cache bash
+RUN apk add --no-cache bash git
COPY entrypoint.sh /
diff --git a/.github/actions/todb-tests/entrypoint.sh b/.github/actions/todb-tests/entrypoint.sh
index 08c83e6..f0c3842 100755
--- a/.github/actions/todb-tests/entrypoint.sh
+++ b/.github/actions/todb-tests/entrypoint.sh
@@ -51,6 +51,23 @@ for file in "$(ls)"; do
fi
done
+# Files added must have date and name later than all existing file
+LATEST_FILE="$(git log -1 --name-status --format="%ct" . | tail -n 1 | awk '{print $2}' | cut -d / -f5)"
+LATEST_FILE_TIME="$(git log -1 --name-status --format="%ct" . | head -n 1 )"
+
+# Get modified times in an array
+mtime_array=()
+arr=($(ls))
+for file in "${arr[@]}"; do
+ mtime_array+=( "$(git log --format=%ct $file)" )
+done
+mtime_length=${#mtime_array[@]}
+
+if [[ $LATEST_FILE_TIME != ${mtime_array[$mtime_length-1]} ]]; then
+ echo "ERROR: latest added file: $LATEST_FILE is not in the right order" >&2;
+ CODE=1;
+fi
+
set +e;
# All new migrations must use 16-digit timestamps.
VIOLATING_FILES="$(ls | sort | cut -d _ -f 1 | sed -n -e '/2020061622101648/,$p' | tr '[:space:]' '\n' | grep -vE '^[0-9]{16}$')";
diff --git a/.github/workflows/traffic.ops.database.yml b/.github/workflows/traffic.ops.database.yml
index a356666..58b1cb7 100644
--- a/.github/workflows/traffic.ops.database.yml
+++ b/.github/workflows/traffic.ops.database.yml
@@ -26,10 +26,14 @@ on:
push:
paths:
- traffic_ops/app/db/**
+ - .github/actions/todb-tests/**
+ - .github/workflows/traffic.ops.database.yml
pull_request:
types: [opened, reopened, ready_for_review, synchronize]
paths:
- traffic_ops/app/db/**
+ - .github/actions/todb-tests/**
+ - .github/workflows/traffic.ops.database.yml
jobs:
tests:
@@ -37,6 +41,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
+ with:
+ fetch-depth: 0
uses: actions/checkout@master
- name: Cache Alpine Docker image
uses: actions/cache@v2
@@ -45,7 +51,7 @@ jobs:
key: docker-images/alpine@${{ env.ALPINE_VERSION }}.tar.gz
- name: Import cached Alpine Docker image
run: .github/actions/save-alpine-tar/entrypoint.sh load ${{ env.ALPINE_VERSION }}
- - name: Rut Traffic Ops Database Tests
- uses: ./.github/actions/todb-tests
+ - name: Run Traffic Ops Database Tests
+ run: ./.github/actions/todb-tests/entrypoint.sh
- name: Save Alpine Docker image
run: .github/actions/save-alpine-tar/entrypoint.sh save ${{ env.ALPINE_VERSION }}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9029b9a..56972d9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- ORT config generation: Added a rule to ip_allow such that PURGE requests are allowed over localhost
### Fixed
+- [#2471](https://github.com/apache/trafficcontrol/issues/2471) - A PR check to ensure added db migration file is the latest.
- [#5609](https://github.com/apache/trafficcontrol/issues/5609) - Fixed GET /servercheck filter for an extra query param.
- [#5565](https://github.com/apache/trafficcontrol/issues/5565) - TO GET /caches/stats panic converting string to uint64
- [#5558](https://github.com/apache/trafficcontrol/issues/5558) - Fixed `TM UI` and `/api/cache-statuses` to report aggregate `bandwidth_kbps` correctly.