You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/02/04 18:07:06 UTC
[trafficcontrol] branch master updated: GitHub Actions: Cache NPM
packages + other speedups (#5494)
This is an automated email from the ASF dual-hosted git repository.
ocket8888 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 d963132 GitHub Actions: Cache NPM packages + other speedups (#5494)
d963132 is described below
commit d963132fdd5dd20d6b07526431604607b14a4ad9
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Thu Feb 4 11:06:49 2021 -0700
GitHub Actions: Cache NPM packages + other speedups (#5494)
* Add a host volume for NPM packages to improve build performance
* GitHub Actions: Cache NPM packages
* Pull ATC builder images
* Hash Perl cache based on OS and cpanfile
* Do not stop containers before actions exit
---
.github/actions/build-rpms/main.js | 22 ++++++++++++++--------
.github/actions/run-ciab/run-ciab.sh | 1 -
.github/actions/to-integration-tests/entrypoint.sh | 10 ----------
.github/workflows/ciab.yaml | 13 ++++++++-----
.github/workflows/tp.e2e.tests.yml | 7 +++++++
.gitignore | 3 ++-
infrastructure/docker/build/docker-compose.yml | 1 +
7 files changed, 32 insertions(+), 25 deletions(-)
diff --git a/.github/actions/build-rpms/main.js b/.github/actions/build-rpms/main.js
index b352a64..02bff7c 100644
--- a/.github/actions/build-rpms/main.js
+++ b/.github/actions/build-rpms/main.js
@@ -20,16 +20,22 @@ const spawnOptions = {
};
let atcComponent = process.env.ATC_COMPONENT;
-const dockerComposeArgs = ["-f", `${process.env.GITHUB_WORKSPACE}/infrastructure/docker/build/docker-compose.yml`, "run", "--rm"];
+const dockerCompose = ["docker-compose", "-f", `${process.env.GITHUB_WORKSPACE}/infrastructure/docker/build/docker-compose.yml`];
if (typeof atcComponent !== "string" || atcComponent.length === 0) {
console.error("Missing environment variable ATC_COMPONENT");
process.exit(1);
}
atcComponent += "_build";
-dockerComposeArgs.push(atcComponent);
-const proc = child_process.spawnSync(
- "docker-compose",
- dockerComposeArgs,
- spawnOptions
-);
-process.exit(proc.status);
+
+function runProcess(...commandArguments) {
+ console.info(...commandArguments);
+ const status = child_process.spawnSync(commandArguments[0], commandArguments.slice(1), spawnOptions).status;
+ if (status === 0) {
+ return;
+ }
+ console.error("Child process \"", ...commandArguments, "\" exited with status code", status, "!");
+ process.exit(status ? status : 1);
+}
+
+runProcess(...dockerCompose, "pull", atcComponent);
+runProcess(...dockerCompose, "run", atcComponent);
diff --git a/.github/actions/run-ciab/run-ciab.sh b/.github/actions/run-ciab/run-ciab.sh
index 6d2323c..022ab8d 100755
--- a/.github/actions/run-ciab/run-ciab.sh
+++ b/.github/actions/run-ciab/run-ciab.sh
@@ -45,5 +45,4 @@ elif exit_code="$(docker inspect --format='{{.State.ExitCode}}' "$($docker_compo
store_ciab_logs;
fi;
-$docker_compose down -v --remove-orphans;
exit "$exit_code";
diff --git a/.github/actions/to-integration-tests/entrypoint.sh b/.github/actions/to-integration-tests/entrypoint.sh
index 582232d..1638c21 100755
--- a/.github/actions/to-integration-tests/entrypoint.sh
+++ b/.github/actions/to-integration-tests/entrypoint.sh
@@ -189,13 +189,3 @@ cd "../testing/api/v$INPUT_VERSION"
cp "${resources}/traffic-ops-test.json" traffic-ops-test.conf
go test -test.v --cfg traffic-ops-test.conf
-CODE=$?
-rm traffic-ops-test.conf
-if [[ "$INPUT_VERSION" -ge 3 ]]; then
- echo 'Stopping Traffic Vault...'
- docker kill "$trafficvault";
-fi;
-echo 'Killing background jobs...';
-kill -9 $(jobs -p);
-
-exit "$CODE"
diff --git a/.github/workflows/ciab.yaml b/.github/workflows/ciab.yaml
index e1c2b89..ce6c0b0 100644
--- a/.github/workflows/ciab.yaml
+++ b/.github/workflows/ciab.yaml
@@ -115,6 +115,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
+ - name: Cache node modules
+ uses: actions/cache@v2
+ with:
+ path: ${{ github.workspace }}/.npm
+ key: ${{ runner.os }}-node-modules-${{ hashFiles('traffic_portal/**/package*.json traffic_portal/bower.json') }}-
+ restore-keys: |
+ ${{ runner.os }}-node-modules-
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
@@ -217,11 +224,7 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ github.workspace }}/infrastructure/cdn-in-a-box/traffic_ops/perl-cache/centos-${{ env.RHEL_VERSION }}/local
- key: ${{ runner.os }}-perl-cache-centos-${{ env.RHEL_VERSION }}-${{ hashFiles('cache/**.tar.gz') }}-${{ hashFiles('**/perllocal.pod') }}
- restore-keys: |
- ${{ runner.os }}-perl-cache-centos-${{ env.RHEL_VERSION }}-${{ hashFiles('cache/**.tar.gz') }}-${{ hashFiles('**/perllocal.pod') }}
- ${{ runner.os }}-perl-cache-centos-${{ env.RHEL_VERSION }}-${{ hashFiles('cache/**.tar.gz') }}-
- ${{ runner.os }}-perl-cache-centos-${{ env.RHEL_VERSION }}-
+ key: ${{ runner.os }}-perl-cache-centos-${{ env.RHEL_VERSION }}-${{ hashFiles('traffic_ops/app/cpanfile') }}
- name: Build CDN-in-a-Box images
uses: ./.github/actions/build-ciab
- name: Start CDN-in-a-Box
diff --git a/.github/workflows/tp.e2e.tests.yml b/.github/workflows/tp.e2e.tests.yml
index 8a8c692..aafe2b7 100644
--- a/.github/workflows/tp.e2e.tests.yml
+++ b/.github/workflows/tp.e2e.tests.yml
@@ -86,6 +86,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
+ - name: Cache node modules
+ uses: actions/cache@v2
+ with:
+ path: ~/.npm
+ key: ${{ runner.os }}-node-modules-${{ hashFiles('traffic_portal/package-lock.json traffic_portal/bower.json') }}
+ restore-keys: |
+ ${{ runner.os }}-node-modules-
- name: Initialize Traffic Ops Database
id: todb
uses: ./.github/actions/todb-init
diff --git a/.gitignore b/.gitignore
index bc67ba7..6f4fd45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,7 +52,8 @@ vendor/**/.travis.yml
/dist
*.pyc
bin/docker-compose
-/.m2
+/.m2/
+/.npm/
/.github/actions/**/node_modules/
# local storage for cdn-in-a-box Carton packages
local.tar.gz
diff --git a/infrastructure/docker/build/docker-compose.yml b/infrastructure/docker/build/docker-compose.yml
index 2e2ef9f..6af13b7 100644
--- a/infrastructure/docker/build/docker-compose.yml
+++ b/infrastructure/docker/build/docker-compose.yml
@@ -73,6 +73,7 @@ services:
RHEL_VERSION: ${RHEL_VERSION:-8}
volumes:
- ../../..:/trafficcontrol:z
+ - ../../../.npm:/root/.npm:z
traffic_router_build:
image: apache/traffic_router_builder:master