From 4723de25bf34a5a762acbf87e5bc9b5f940fb01c Mon Sep 17 00:00:00 2001 From: Reuben Morais Date: Fri, 18 Dec 2020 16:40:07 +0000 Subject: [PATCH] Use payload.env instead of forwarding variables manually --- .taskcluster.yml | 19 +++++++++---------- taskcluster/tc-schedule.sh | 19 ++----------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 8ebc5cb8..77d20b50 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -49,7 +49,14 @@ tasks: taskclusterProxy: true env: - TC_DECISION_SHA: ef67832e6657f43e139a10f37eb326a7d9d96dad + TASK_ID: ${metadata.task_id} + GITHUB_HEAD_USER_LOGIN: ${metadata.github.login} + GITHUB_HEAD_USER_EMAIL: ${metadata.github.login}@users.noreply.github.com + GITHUB_EVENT: ${metadata.github.action} + GITHUB_HEAD_REPO_URL: ${metadata.github.clone_url} + GITHUB_HEAD_BRANCH: ${metadata.github.ref} + GITHUB_HEAD_REF: ${metadata.github.ref} + GITHUB_HEAD_SHA: ${metadata.github.sha} command: - "/bin/bash" @@ -62,15 +69,7 @@ tasks: cd /home/build-user/ && echo -e "#!/bin/bash\nset -xe\nenv && id && mkdir ~/DeepSpeech/ && git clone --quiet ${metadata.github.clone_url} ~/DeepSpeech/ds/ && cd ~/DeepSpeech/ds && git checkout --quiet ${metadata.github.ref}" > /tmp/clone.sh && chmod +x /tmp/clone.sh && sudo -H -u build-user /bin/bash /tmp/clone.sh && - sudo -H -u build-user --preserve-env /bin/bash /home/build-user/DeepSpeech/ds/taskcluster/tc-schedule.sh \ - TASK_ID=${metadata.task_id} \ - GITHUB_HEAD_USER_LOGIN=${metadata.github.login} \ - GITHUB_HEAD_USER_EMAIL=${metadata.github.login}@users.noreply.github.com \ - GITHUB_EVENT=${metadata.github.action} \ - GITHUB_HEAD_REPO_URL=${metadata.github.clone_url} \ - GITHUB_HEAD_BRANCH=${metadata.github.ref} \ - GITHUB_HEAD_REF=${metadata.github.ref} \ - GITHUB_HEAD_SHA=${metadata.github.sha} + sudo -H -u build-user --preserve-env /bin/bash /home/build-user/DeepSpeech/ds/taskcluster/tc-schedule.sh artifacts: "public": type: "directory" diff --git a/taskcluster/tc-schedule.sh b/taskcluster/tc-schedule.sh index 2a909bf1..fc106f4a 100755 --- a/taskcluster/tc-schedule.sh +++ b/taskcluster/tc-schedule.sh @@ -1,11 +1,6 @@ #!/bin/bash set -ex -# Set environment variables passed in arguments -for line in $@; do - eval "$line" -done - curdir=$(dirname "$0")/ pip3 install --quiet --user --upgrade pip @@ -40,19 +35,9 @@ GITHUB_HEAD_USER_EMAIL="email" \ python3 ${curdir}/tc-decision.py --dry # Create a new env variable for usage in TaskCluster .yml files -GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}" +export GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}" # Quick hack because tc-decision uses GITHUB_HEAD_BRANCH -GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}" +export GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}${GITHUB_HEAD_TAG}" -# Forward all variables to tc-decision.py -GITHUB_EVENT="$GITHUB_EVENT" \ -TASK_ID="$TASK_ID" \ -GITHUB_HEAD_BRANCHORTAG="${GITHUB_HEAD_BRANCHORTAAG}" \ -GITHUB_HEAD_BRANCH="${GITHUB_HEAD_BRANCH}" \ -GITHUB_HEAD_REF="$GITHUB_HEAD_REF" \ -GITHUB_HEAD_SHA="$GITHUB_HEAD_SHA" \ -GITHUB_HEAD_REPO_URL="$GITHUB_HEAD_REPO_URL" \ -GITHUB_HEAD_USER_LOGIN="$GITHUB_HEAD_USER_LOGIN" \ -GITHUB_HEAD_USER_EMAIL="$GITHUB_HEAD_USER_EMAIL" \ python3 ${curdir}/tc-decision.py