Skip to content

Commit

Permalink
WIP: test failed build
Browse files Browse the repository at this point in the history
  • Loading branch information
maciektr committed Nov 7, 2023
1 parent 0bdb487 commit ce79240
Showing 1 changed file with 138 additions and 136 deletions.
274 changes: 138 additions & 136 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,58 @@ jobs:
nightly_version: ${{ steps.version.outputs.nightly_version }}
nightly_branch: ${{ steps.version.outputs.nightly_branch }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable

- name: Configure Git for committing
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Build xtasks
run: cargo build -p xtask

- name: Upgrade Cairo to latest main commit
run: cargo xtask set-cairo-version --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')

- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask

- name: Determine nightly version
id: version
shell: bash
run: |
NIGHTLY_TAG=$(cargo xtask get-nightly-version --tag)
NIGHTLY_VERSION=$(cargo xtask get-nightly-version)
NIGHTLY_BRANCH="nightly/tmp/$NIGHTLY_TAG"
echo "NIGHTLY_TAG=$NIGHTLY_TAG" >> $GITHUB_ENV
echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> $GITHUB_ENV
echo "NIGHTLY_BRANCH=$NIGHTLY_BRANCH" >> $GITHUB_ENV
echo "nightly_tag=$NIGHTLY_TAG" >> $GITHUB_OUTPUT
echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
echo "nightly_branch=$NIGHTLY_BRANCH" >> $GITHUB_OUTPUT
- name: Set Scarb version build metadata
run: cargo xtask set-scarb-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release

- name: Rebuild xtasks after Cargo.toml changes
run: cargo build -p xtask

- name: Compose release notes
run: cargo xtask nightly-release-notes > NIGHTLY_RELEASE_NOTES.md

- name: Commit patches
run: |
git checkout -b ${{ env.NIGHTLY_BRANCH }}
git add .
git commit -m ${{ env.NIGHTLY_TAG }}
# NOTE: This must be the last operation done in this job in order for cleanup job to work properly.
- name: Push patches to the repository
run: git push origin ${{ env.NIGHTLY_BRANCH }}
- run: exit 1
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@stable
#
# - name: Configure Git for committing
# run: |
# git config user.name github-actions
# git config user.email [email protected]
#
# - name: Build xtasks
# run: cargo build -p xtask
#
# - name: Upgrade Cairo to latest main commit
# run: cargo xtask set-cairo-version --rev $(git ls-remote --refs "https://github.com/starkware-libs/cairo" main | awk '{print $1}')
#
# - name: Rebuild xtasks after Cargo.toml changes
# run: cargo build -p xtask
#
# - name: Determine nightly version
# id: version
# shell: bash
# run: |
# NIGHTLY_TAG=$(cargo xtask get-nightly-version --tag)
# NIGHTLY_VERSION=$(cargo xtask get-nightly-version)
# NIGHTLY_BRANCH="nightly/tmp/$NIGHTLY_TAG"
#
# echo "NIGHTLY_TAG=$NIGHTLY_TAG" >> $GITHUB_ENV
# echo "NIGHTLY_VERSION=$NIGHTLY_VERSION" >> $GITHUB_ENV
# echo "NIGHTLY_BRANCH=$NIGHTLY_BRANCH" >> $GITHUB_ENV
#
# echo "nightly_tag=$NIGHTLY_TAG" >> $GITHUB_OUTPUT
# echo "nightly_version=$NIGHTLY_VERSION" >> $GITHUB_OUTPUT
# echo "nightly_branch=$NIGHTLY_BRANCH" >> $GITHUB_OUTPUT
#
# - name: Set Scarb version build metadata
# run: cargo xtask set-scarb-version --build ${{ env.NIGHTLY_TAG }} --no-pre-release
#
# - name: Rebuild xtasks after Cargo.toml changes
# run: cargo build -p xtask
#
# - name: Compose release notes
# run: cargo xtask nightly-release-notes > NIGHTLY_RELEASE_NOTES.md
#
# - name: Commit patches
# run: |
# git checkout -b ${{ env.NIGHTLY_BRANCH }}
# git add .
# git commit -m ${{ env.NIGHTLY_TAG }}
#
# # NOTE: This must be the last operation done in this job in order for cleanup job to work properly.
# - name: Push patches to the repository
# run: git push origin ${{ env.NIGHTLY_BRANCH }}

check:
uses: ./.github/workflows/_check-release.yml
Expand All @@ -84,95 +85,96 @@ jobs:
ref: ${{ needs.prepare.outputs.nightly_branch }}
fail-fast: false

release:
uses: ./.github/workflows/_build-release.yml
needs: prepare
with:
scarb-tag: v${{ needs.prepare.outputs.nightly_version }}
ref: ${{ needs.prepare.outputs.nightly_branch }}

upload:
runs-on: ubuntu-latest
needs: [ prepare, release ]
# Do not run on dry_run
if: ${{ !(inputs.dry_run) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ needs.prepare.outputs.nightly_branch }}

- name: Create source code archives
run: |
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.zip" HEAD
git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz" HEAD
- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts-dl

- name: Unpack artifacts to staging directory
run: |
mkdir -p artifacts
mv artifacts-dl/build-*/scarb-* artifacts/
mv artifacts-dl/checksums/* artifacts/
ls -lh artifacts/
- name: Create GitHub release
run: |
gh release create \
"${{ needs.prepare.outputs.nightly_tag }}" \
--repo software-mansion/scarb-nightlies \
--latest \
--title "${{ needs.prepare.outputs.nightly_tag }}" \
--notes-file NIGHTLY_RELEASE_NOTES.md
env:
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}

- name: Upload release assets
run: |
for file in \
./artifacts/* \
"scarb-${{ needs.prepare.outputs.nightly_tag }}.zip#Scarb source code (zip)" \
"scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz#Scarb source code (tar.gz)"
do
# If there isn't # in name, it means that it is a build artifact
# and we need to remove version tag from the name, so it can be
# easily accessed in asdf and Scarb installation scripts
#
# for example:
# scarb-v0.6.0+nightly-2023-08-09-aarch64-apple-darwin.tar.gz
# becomes
# scarb-nightly-2023-08-09-aarch64-apple-darwin.tar.gz
if ! [[ $(grep "#" <<< $file) ]]; then
label=$(echo $file | sed -E "s/v[^+]*\+//" | sed -E "s/.\/artifacts\///")
cp "$file" "$label"
file="$label"
fi
gh release upload \
"${{ needs.prepare.outputs.nightly_tag }}" \
"$file" \
--repo software-mansion/scarb-nightlies
done
env:
GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}

cleanup:
runs-on: ubuntu-latest
if: always() && needs.prepare.result == 'success'
needs: [ prepare, upload ]
steps:
- uses: actions/checkout@v4
- name: Delete nightly branch
run: |
git push origin -d ${{ needs.prepare.outputs.nightly_branch }}
# release:
# uses: ./.github/workflows/_build-release.yml
# needs: prepare
# with:
# scarb-tag: v${{ needs.prepare.outputs.nightly_version }}
# ref: ${{ needs.prepare.outputs.nightly_branch }}
#
# upload:
# runs-on: ubuntu-latest
# needs: [ prepare, release ]
# # Do not run on dry_run
# if: ${{ !(inputs.dry_run) }}
# steps:
# - uses: actions/checkout@v4
# with:
# ref: ${{ needs.prepare.outputs.nightly_branch }}

# - name: Create source code archives
# run: |
# git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.zip" HEAD
# git archive "--prefix=scarb-${{ needs.prepare.outputs.nightly_tag }}/" -o "scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz" HEAD
#
# - name: Download artifacts
# uses: actions/download-artifact@v3
# with:
# path: artifacts-dl
#
# - name: Unpack artifacts to staging directory
# run: |
# mkdir -p artifacts
# mv artifacts-dl/build-*/scarb-* artifacts/
# mv artifacts-dl/checksums/* artifacts/
# ls -lh artifacts/
#
# - name: Create GitHub release
# run: |
# gh release create \
# "${{ needs.prepare.outputs.nightly_tag }}" \
# --repo software-mansion/scarb-nightlies \
# --latest \
# --title "${{ needs.prepare.outputs.nightly_tag }}" \
# --notes-file NIGHTLY_RELEASE_NOTES.md
# env:
# GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}
#
# - name: Upload release assets
# run: |
# for file in \
# ./artifacts/* \
# "scarb-${{ needs.prepare.outputs.nightly_tag }}.zip#Scarb source code (zip)" \
# "scarb-${{ needs.prepare.outputs.nightly_tag }}.tar.gz#Scarb source code (tar.gz)"
# do
# # If there isn't # in name, it means that it is a build artifact
# # and we need to remove version tag from the name, so it can be
# # easily accessed in asdf and Scarb installation scripts
# #
# # for example:
# # scarb-v0.6.0+nightly-2023-08-09-aarch64-apple-darwin.tar.gz
# # becomes
# # scarb-nightly-2023-08-09-aarch64-apple-darwin.tar.gz
# if ! [[ $(grep "#" <<< $file) ]]; then
# label=$(echo $file | sed -E "s/v[^+]*\+//" | sed -E "s/.\/artifacts\///")
# cp "$file" "$label"
# file="$label"
# fi
#
# gh release upload \
# "${{ needs.prepare.outputs.nightly_tag }}" \
# "$file" \
# --repo software-mansion/scarb-nightlies
# done
# env:
# GH_TOKEN: ${{ secrets.SCARB_NIGHTLIES_CONTENTS_WRITE }}

# cleanup:
# runs-on: ubuntu-latest
# if: always() && needs.prepare.result == 'success'
# needs: [ prepare, upload ]
# steps:
# - uses: actions/checkout@v4
# - name: Delete nightly branch
# run: |
# git push origin -d ${{ needs.prepare.outputs.nightly_branch }}

notify_failed:
runs-on: ubuntu-latest
# Do not run on dry_run or success
if: always() && ${{ !(inputs.dry_run) }} && contains(needs.*.result, 'failure')
needs: [ cleanup, upload, release, prepare ]
# if: always() && ${{ !(inputs.dry_run) }} && contains(needs.*.result, 'failure')
if: always() && !(inputs.dry_run) && contains(needs.*.result, 'failure')
needs: [ prepare ]
steps:
- name: Notifying about Nightly fail!
uses: slackapi/[email protected]
Expand Down

0 comments on commit ce79240

Please sign in to comment.