Skip to content

Commit

Permalink
Update and simplify the dockerhub account logics
Browse files Browse the repository at this point in the history
It also debugs ratelimit both with registered account
and anon to track incorrect dockerhub calls.

Signed-off-by: Cédric Ollivier <[email protected]>
  • Loading branch information
collivier committed Jan 14, 2025
1 parent 61ddf78 commit 5f5f193
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ jobs:
fail-fast: false
matrix: ${{fromJson(needs.tests.outputs.matrix)}}
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Cleanup Tmp DIR
run: |
sudo rm -rf /tmp/*
Expand Down Expand Up @@ -153,21 +158,13 @@ jobs:
- name: Run Crystal Spec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_USERNAMES: ${{ secrets.DOCKERHUB_USERNAMES }}
DOCKERHUB_PASSWORDS: ${{ secrets.DOCKERHUB_PASSWORDS }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_EMAIL: ${{ secrets.DOCKERHUB_EMAIL }}
IMAGE_REPO: ${{ secrets.IMAGE_REPO }}
run: |
USERNAME_ARRAY=($DOCKERHUB_USERNAMES)
PASSWORD_ARRAY=($DOCKERHUB_PASSWORDS)
EMAIL_ARRAY=($DOCKERHUB_EMAIL)
IMAGE_ARRAY=($IMAGE_REPO)
RANDOMIZER=$(( 0 + $RANDOM % 3 ))
export DOCKERHUB_USERNAME=${USERNAME_ARRAY[$RANDOMIZER]}
export DOCKERHUB_PASSWORD=${PASSWORD_ARRAY[$RANDOMIZER]}
export PROTECTED_DOCKERHUB_USERNAME=$DOCKERHUB_USERNAME
export PROTECTED_DOCKERHUB_PASSWORD=$DOCKERHUB_PASSWORD
export PROTECTED_DOCKERHUB_EMAIL=${EMAIL_ARRAY[$RANDOMIZER]}
Expand All @@ -186,10 +183,13 @@ jobs:
#done
crystal build src/cnf-testsuite.cr
./cnf-testsuite setup
LOG_LEVEL=info crystal spec --warnings none --tag ${{ matrix.spec }} -v
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
echo get ratelimit with a user account $DOCKERHUB_USERNAME
TOKEN=$(curl --user "$DOCKERHUB_USERNAME:$DOCKERHUB_PASSWORD" "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand All @@ -200,6 +200,7 @@ jobs:
kubectl get all -A || true
kind delete cluster --name $CLUSTER --verbosity 1
continue-on-error: true

- name: upload artifact
if: ${{ always() }}
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -282,6 +283,9 @@ jobs:
sleep 1
done
LOG_LEVEL=info crystal spec --warnings none --tag ${{ matrix.tag }} -v
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -396,6 +400,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~compatibility ~resilience ~reasonable_startup_time ~reasonable_image_size ~platform ~increase_capacity ~decrease_capacity ~install_script_helm ~helm_chart_valid ~helm_chart_published verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -476,6 +483,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~compatibility ~pod_network_latency ~platform ~increase_capacity ~decrease_capacity ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~install_script_helm ~helm_chart_valid ~helm_chart_published ~rollback ~secrets_used ~immutable_configmap verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down Expand Up @@ -556,6 +566,9 @@ jobs:
wget -O cnf-testsuite.yml https://raw.githubusercontent.com/cnti-testcatalog/testsuite/${GITHUB_SHA}/example-cnfs/coredns/cnf-testsuite.yml
./cnf-testsuite cnf_install cnf-config=./cnf-testsuite.yml
LOG_LEVEL=info ./cnf-testsuite all ~resilience ~platform ~liveness ~readiness ~rolling_update ~rolling_downgrade ~rolling_version_change ~nodeport_not_used ~hostport_not_used ~hardcoded_ip_addresses_in_k8s_runtime_configuration ~rollback ~secrets_used ~immutable_configmap ~reasonable_startup_time ~reasonable_image_size verbose
echo get ratelimit anonymously
TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest
- name: Delete Cluster
if: ${{ always() }}
run: |
Expand Down

0 comments on commit 5f5f193

Please sign in to comment.