Skip to content

Commit

Permalink
updates CI ci:debug
Browse files Browse the repository at this point in the history
  • Loading branch information
saxix committed Jun 11, 2024
1 parent 193b83d commit 447f581
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 9 deletions.
19 changes: 15 additions & 4 deletions .github/actions/image_updated/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ runs:
architecture=${{ inputs.architecture }}
repo="${ref%:*}"
tag="${ref##*:}"
echo "image=$ref" >> $GITHUB_OUTPUT
echo "repo=$repo" >> $GITHUB_OUTPUT
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "architecture=$architecture" >> $GITHUB_OUTPUT
res=$(curl -s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull")
res=$(curl -u "${{ inputs.username }}:${{ inputs.password }}" \
-s "https://auth.docker.io/token?service=registry.docker.io&scope=repository:${repo}:pull")
token=$(echo $res | jq -r '.token')
if [[ -z "$token" ]];then
Expand All @@ -64,12 +67,11 @@ runs:
id: check
shell: bash
run: |
echo "Repo: ${{steps.setup.outputs.repo}}"
url="https://registry-1.docker.io/v2/${{steps.setup.outputs.repo}}/manifests/${{steps.setup.outputs.tag}}"
manifest=$(curl -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
-H 'Authorization: Bearer ${{steps.setup.outputs.token}}' \
-s $url)
if [[ $manifest == *MANIFEST_UNKNOWN* ]];then
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "updated=false" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -108,13 +110,22 @@ runs:
echo "::error title=⛔ error hint::Digest is empty"
exit 1
fi
url=https://registry-1.docker.io/v2/${{steps.setup.outputs.repo}}/blobs/$digest
url=https://registry-1.docker.io/v2/${{steps.setup.outputs.repo}}/blobs/$digest
blob=$(curl \
--silent \
--location \
-H "Accept: application/vnd.docker.disribution.manifest.v2+json" \
-H 'Authorization: Bearer ${{steps.setup.outputs.token}}' \
$url )
if [[ $blob == *BLOB_UNKNOWN* ]];then
code=$(echo $blob | jq .errors[0].code)
message=$(echo $blob | jq .errors[0].message)
echo "::error title=$code error hint::$message $url"
exit 1
fi
if [[ -z "$blob" ]]; then
echo "Unable to get blob from: https://registry-1.docker.io/v2/$repo/blobs/$digest"
echo "updated=false" >> "$GITHUB_OUTPUT"
Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/dump.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: "[DEBUG] Dump"

on:
check_run:
create:
delete:
discussion:
discussion_comment:
fork:
issues:
issue_comment:
milestone:
pull_request:
pull_request_review_comment:
pull_request_review:
push:
release:
workflow_dispatch:


jobs:
dump:
name: "[DEBUG] Echo Full Context"
if: ${{ contains(github.event.head_commit.message, 'ci:debug') }}
runs-on: [ubuntu-latest, self-hosted]
steps:
- name: Dump Env vars
run: |
echo "====== ENVIRONMENT ================="
env | sort
echo "===================================="
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo "====== GITHUB_CONTEXT =============="
echo "$GITHUB_CONTEXT"
echo "===================================="
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJSON(job) }}
run: |
echo "====== JOB_CONTEXT =============="
echo "$JOB_CONTEXT"
echo "===================================="
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJSON(steps) }}
run: |
echo "====== STEPS_CONTEXT =============="
echo "$STEPS_CONTEXT"
echo "===================================="
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJSON(runner) }}
run: |
echo "====== RUNNER_CONTEXT =============="
echo "$RUNNER_CONTEXT"
echo "===================================="
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
run: |
echo "====== STRATEGY_CONTEXT =============="
echo "$STRATEGY_CONTEXT"
echo "===================================="
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJSON(matrix) }}
run: |
echo "====== MATRIX_CONTEXT =============="
echo "$MATRIX_CONTEXT"
echo "===================================="
- name: Dump vars context
env:
VARS_CONTEXT: ${{ toJSON(vars) }}
run: |
echo "====== VARS =============="
echo "$VARS_CONTEXT"
echo "===================================="
- name: Dump env context
env:
ENV_CONTEXT: ${{ toJSON(env) }}
run: |
echo "====== ENV =============="
echo "$ENV_CONTEXT"
echo "===================================="
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ jobs:
id: image_name
run: |
echo "name=${{vars.DOCKER_IMAGE}}:test-${{steps.meta.outputs.version}}" >> $GITHUB_OUTPUT
- id: image_updated
name: Check if image exists and updated
uses: ./.github/actions/image_updated
with:
image: unicef/hope-dedupe-engine:test-feature-ci_rc
checksum: 00f2f954
username: ${{ secrets.username }}
password: ${{ secrets.password }}

build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
uses: ./.github/workflows/_build.yml
Expand Down Expand Up @@ -97,8 +106,6 @@ jobs:
uses: actions/checkout@v2
- name: Run tests
run: |
ls -al $PWD
touch __PIPPO__
docker run --rm \
-e DATABASE_URL=postgres://postgres:postgres@db:5432/dedupe \
-e SECRET_KEY=secret_key \
Expand All @@ -108,7 +115,6 @@ jobs:
-w /code/app \
-t ${{needs.setup.outputs.image_name}} \
pytest tests -v
ls -al $PWD
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ __pycache__/
!.trivyignore
!docker/bin/*.sh
!bandit.yaml
build
dist
/build
/dist
coverage.xml
Makefile
site
Expand Down

0 comments on commit 447f581

Please sign in to comment.