Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0f5d5fa
feat(ci): implement image caching
shreemaan-abhishek Jan 29, 2023
4b74e0d
fix: rename buckup to backup
shreemaan-abhishek Jan 29, 2023
8766547
reformat code
shreemaan-abhishek Jan 29, 2023
e7df672
encapsulate
shreemaan-abhishek Jan 29, 2023
fae9911
fix incorrect variable name
shreemaan-abhishek Jan 29, 2023
374e39f
replace negated -z with -n
shreemaan-abhishek Jan 29, 2023
bd6b858
add new line
shreemaan-abhishek Jan 29, 2023
8c563bf
replace lanuch with launch
shreemaan-abhishek Jan 29, 2023
6337e12
merge launch common svcs and launch svcs steps
shreemaan-abhishek Jan 29, 2023
03b532d
fix shellcheck error
shreemaan-abhishek Jan 29, 2023
f0cda12
encapsulate to separate bash scripts
shreemaan-abhishek Jan 30, 2023
3f1274d
add echo commands
shreemaan-abhishek Jan 31, 2023
a5a021a
add new line
shreemaan-abhishek Jan 31, 2023
8b49bea
encapsulate
shreemaan-abhishek Feb 1, 2023
63bc306
update files to be hashed
shreemaan-abhishek Feb 1, 2023
94e66c7
use format function for hashFile path
shreemaan-abhishek Feb 1, 2023
18c12be
fix lint errors
shreemaan-abhishek Feb 1, 2023
c402763
add logs
shreemaan-abhishek Feb 1, 2023
39d0240
add more logs
shreemaan-abhishek Feb 1, 2023
15cb0ef
add make command
shreemaan-abhishek Feb 1, 2023
754a67f
fix store password
shreemaan-abhishek Feb 1, 2023
d95c880
add check
shreemaan-abhishek Feb 2, 2023
ebe06c3
Revert "add check"
shreemaan-abhishek Feb 2, 2023
6593836
build function image only when cache miss
shreemaan-abhishek Feb 2, 2023
0db11d1
add "after" as positional parameter
shreemaan-abhishek Feb 2, 2023
912790f
don\'t cache common images
shreemaan-abhishek Feb 2, 2023
940fd54
delete redundant scripts
shreemaan-abhishek Feb 2, 2023
1ff4bbf
combine 3 steps to one
shreemaan-abhishek Feb 2, 2023
d9489f3
combine 3 steps to one
shreemaan-abhishek Feb 2, 2023
850a725
fix indentation
shreemaan-abhishek Feb 6, 2023
9c72fe6
add echo command
shreemaan-abhishek Feb 6, 2023
3ca5329
add echo command
shreemaan-abhishek Feb 6, 2023
2360006
combine 3 steps to one
shreemaan-abhishek Feb 6, 2023
6c45b80
replace if-else with case
shreemaan-abhishek Feb 6, 2023
54af0b4
remove logs
shreemaan-abhishek Feb 6, 2023
165c046
fix non-zero exit code error
shreemaan-abhishek Feb 6, 2023
3dbd35f
isolate saving docker images to a separate step
shreemaan-abhishek Feb 8, 2023
05ce727
remove whitespace
shreemaan-abhishek Feb 8, 2023
34b7037
add conditional
shreemaan-abhishek Feb 8, 2023
6dcb77c
delete backup archive after loading images
shreemaan-abhishek Feb 8, 2023
d2c4821
delete some files to preserve space
shreemaan-abhishek Feb 8, 2023
550f2fa
update key name
shreemaan-abhishek Feb 8, 2023
ed01f7f
Trigger Build
shreemaan-abhishek Feb 8, 2023
78a3794
add script to free disk space
shreemaan-abhishek Feb 9, 2023
ea08ca4
trigger build
shreemaan-abhishek Feb 9, 2023
2c3eaa3
add appropriate indentations
shreemaan-abhishek Feb 10, 2023
9e7d282
use four space indentation
shreemaan-abhishek Feb 14, 2023
e4d38d3
add comment
shreemaan-abhishek Feb 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 35 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,30 +99,36 @@ jobs:
rm -rf $(ls -1 --ignore=*.tgz --ignore=ci --ignore=t --ignore=utils --ignore=.github)
tar zxvf ${{ steps.branch_env.outputs.fullname }}

- name: Start CI env (FIRST_TEST)
if: steps.test_env.outputs.type == 'first'
run: |
# launch deps env
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
- name: Cache images
id: cache-images
uses: actions/cache@v3
env:
cache-name: cache-apisix-docker-images
with:
path: docker-images-backup
key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.test_env.outputs.type }}-${{ matrix.os_name }}-${{ hashFiles(format('./ci/pod/docker-compose.{0}.yml', steps.test_env.outputs.type )) }}

- name: Start CI env (PLUGIN_TEST)
if: steps.test_env.outputs.type == 'plugin'
- if: ${{ steps.cache-images.outputs.cache-hit == 'true' }}
name: Load saved docker images
run: |
# download keycloak cas provider
sudo wget https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar -O /opt/keycloak-protocol-cas-18.0.2.jar

./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh

- name: Start CI env (LAST_TEST)
if: steps.test_env.outputs.type == 'last'
if [[ -f docker-images-backup/apisix-images.tar ]]; then
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
docker load --input docker-images-backup/apisix-images.tar
rm docker-images-backup/apisix-images.tar
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
echo "loaded docker images"
if [[ ${{ steps.test_env.outputs.type }} != first ]]; then
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
fi
fi
- if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}
name: Linux launch services
run: |
# generating SSL certificates for Kafka
sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 2048 -storepass changeit
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
[[ ${{ steps.test_env.outputs.type }} == plugin ]] && ./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh

[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
echo "Linux launch services, done."
- name: Start Dubbo Backend
if: matrix.os_name == 'linux_openresty' && steps.test_env.outputs.type == 'plugin'
run: |
Expand Down Expand Up @@ -158,3 +164,12 @@ jobs:
env:
TEST_FILE_SUB_DIR: ${{ matrix.test_dir }}
run: sudo -E ./ci/${{ matrix.os_name }}_runner.sh script

- if: ${{ steps.cache-images.outputs.cache-hit != 'true' }}
name: Save docker images
run: |
# free disk space
bash ./ci/free_disk_space.sh
echo "start backing up, $(date)"
bash ./ci/backup-docker-images.sh ${{ steps.test_env.outputs.type }}
echo "backup done, $(date)"
25 changes: 5 additions & 20 deletions .github/workflows/centos7-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,13 @@ jobs:
docker run -itd -v /home/runner/work/apisix/apisix:/apisix --env TEST_FILE_SUB_DIR="$TEST_FILE_SUB_DIR" --name centos7Instance --net="host" --dns 8.8.8.8 --dns-search apache.org docker.io/centos:7 /bin/bash
# docker exec centos7Instance bash -c "cp -r /tmp/apisix ./"

- name: Start CI env (FIRST_TEST)
if: steps.test_env.outputs.type == 'first'
- name: Linux launch services
run: |
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
[[ ${{ steps.test_env.outputs.type }} == plugin ]] && ./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml

- name: Start CI env (PLUGIN_TEST)
if: steps.test_env.outputs.type == 'plugin'
run: |
# download keycloak cas provider
sudo wget https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar -O /opt/keycloak-protocol-cas-18.0.2.jar

./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh

- name: Start CI env (LAST_TEST)
if: steps.test_env.outputs.type == 'last'
run: |
# generating SSL certificates for Kafka
keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 2048 -storepass changeit
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
echo "Linux launch services, done"

- name: Install dependencies
run: |
Expand Down
27 changes: 6 additions & 21 deletions .github/workflows/fips.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,14 @@ jobs:
run: |
make ci-env-up project_compose_ci=ci/pod/docker-compose.common.yml

- name: Start CI env (FIRST_TEST)
if: steps.test_env.outputs.type == 'first'
- name: Linux launch services
run: |
# launch deps env
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
[[ ${{ steps.test_env.outputs.type }} == plugin ]] && ./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml

- name: Start CI env (PLUGIN_TEST)
if: steps.test_env.outputs.type == 'plugin'
run: |
# download keycloak cas provider
sudo wget https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar -O /opt/keycloak-protocol-cas-18.0.2.jar

./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh

- name: Start CI env (LAST_TEST)
if: steps.test_env.outputs.type == 'last'
run: |
# generating SSL certificates for Kafka
sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 2048 -storepass changeit
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
echo "make ci-env-up, done"
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
echo "Linux launch services, done"

- name: Linux Before install
run: sudo ./ci/${{ matrix.os_name }}_runner.sh before_install
Expand Down
26 changes: 5 additions & 21 deletions .github/workflows/gm-cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,29 +86,13 @@ jobs:
make ci-env-up project_compose_ci=ci/pod/docker-compose.common.yml
sudo ./ci/init-common-test-service.sh

- name: Start CI env (FIRST_TEST)
if: steps.test_env.outputs.type == 'first'
- name: Linux launch services
run: |
# launch deps env
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh before
[[ ${{ steps.test_env.outputs.type }} == plugin ]] && ./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml

- name: Start CI env (PLUGIN_TEST)
if: steps.test_env.outputs.type == 'plugin'
run: |
# download keycloak cas provider
sudo wget https://github.com/jacekkow/keycloak-protocol-cas/releases/download/18.0.2/keycloak-protocol-cas-18.0.2.jar -O /opt/keycloak-protocol-cas-18.0.2.jar

./ci/pod/openfunction/build-function-image.sh
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh

- name: Start CI env (LAST_TEST)
if: steps.test_env.outputs.type == 'last'
run: |
# generating SSL certificates for Kafka
sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 2048 -storepass changeit
make ci-env-up project_compose_ci=ci/pod/docker-compose.${{ steps.test_env.outputs.type }}.yml
sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh
[[ ${{ steps.test_env.outputs.type }} != first ]] && sudo ./ci/init-${{ steps.test_env.outputs.type }}-test-service.sh after
echo "Linux launch services, done."

- name: Start Dubbo Backend
if: steps.test_env.outputs.type == 'plugin'
Expand Down
50 changes: 50 additions & 0 deletions ci/backup-docker-images.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

test_type=$1

echo "started backing up, time: $(date)"
mkdir docker-images-backup
sum=$(cat ci/pod/docker-compose.$test_type.yml | grep image | wc -l)
special_tag=$(cat ci/pod/docker-compose.$test_type.yml | grep image: | awk '{print $2}' | awk 'ORS=NR%"'$sum'"?" ":"\n"{print}')
echo special: $special_tag
openwhisk_tag="openwhisk/action-nodejs-v14:nightly openwhisk/standalone:nightly"
echo
echo special_tag: $special_tag
echo openwhisk_tag: $openwhisk_tag
echo
all_tags="${special_tag} ${openwhisk_tag}"
to_pull=""

for tag in $all_tags
do
if ! ( docker inspect $tag &> /dev/null )
then
to_pull="${to_pull} ${tag}"
fi
done

echo to pull : $to_pull

if [[ -n $to_pull ]]
then
echo "$to_pull" | xargs -P10 -n1 docker pull
fi

docker save $special_tag $openwhisk_tag -o docker-images-backup/apisix-images.tar
echo "docker save done, time: $(date)"
31 changes: 31 additions & 0 deletions ci/free_disk_space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# GitHub Action CI runner comes with a limited disk space, due to several reasons
# it may become full. For example, caching docker images creates an archive of
# several GBs of size, this sometimes leads to disk usage becoming full.
# To keep CI functional, we delete large directories that we do not need.

echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="

df -h
echo "Removing unnecessary large directories"
sudo rm -rf /usr/local/lib/android /usr/share/dotnet /usr/share/swift
df -h
37 changes: 26 additions & 11 deletions ci/init-last-test-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,30 @@
# limitations under the License.
#

docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
docker exec -i apache-apisix_kafka-server2_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test-consumer
before() {
# generating SSL certificates for Kafka
sudo keytool -genkeypair -keyalg RSA -dname "CN=127.0.0.1" -alias 127.0.0.1 -keystore ./ci/pod/kafka/kafka-server/selfsigned.jks -validity 365 -keysize 2048 -storepass changeit
}

# create messages for test-consumer
for i in `seq 30`
do
docker exec -i apache-apisix_kafka-server1_1 bash -c "echo "testmsg$i" | /opt/bitnami/kafka/bin/kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic test-consumer"
echo "Produces messages to the test-consumer topic, msg: testmsg$i"
done
echo "Kafka service initialization completed"
after() {
docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test2
docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 3 --topic test3
docker exec -i apache-apisix_kafka-server2_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server2:2181 --replication-factor 1 --partitions 1 --topic test4
docker exec -i apache-apisix_kafka-server1_1 /opt/bitnami/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper-server1:2181 --replication-factor 1 --partitions 1 --topic test-consumer
# create messages for test-consumer
for i in `seq 30`
do
docker exec -i apache-apisix_kafka-server1_1 bash -c "echo "testmsg$i" | /opt/bitnami/kafka/bin/kafka-console-producer.sh --bootstrap-server 127.0.0.1:9092 --topic test-consumer"
echo "Produces messages to the test-consumer topic, msg: testmsg$i"
done
echo "Kafka service initialization completed"
}

case $1 in
'after')
after
;;
'before')
before
;;
esac
Loading