This repository has been archived by the owner on Oct 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create E2E test on main branch (#24)
* Create e2e_test.yml
- Loading branch information
1 parent
1aec73a
commit c196049
Showing
1 changed file
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: E2E Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
|
||
jobs: | ||
upload: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
name: cache upload (${{ matrix.os }}) | ||
steps: | ||
- name: Create file to cache | ||
run: | | ||
mkdir test-cache | ||
echo "foo" > test-cache/test.txt | ||
- uses: actions/cache@v3 | ||
with: | ||
path: test-cache | ||
key: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }} | ||
canary: | ||
needs: upload | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
CacheKey: ${{ matrix.os }}-runner-${{ github.run_number }}-${{ github.run_attempt }} | ||
steps: | ||
- name: checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Restore Go modules cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/go/pkg/mod | ||
key: go-${{ runner.os }}-${{ hashFiles('go.mod') }} | ||
restore-keys: | | ||
go-${{ runner.os }}- | ||
- name: Build the project | ||
run: go build | ||
- name: Install extension | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} | ||
run: gh extensions install . | ||
- name: Print help | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} | ||
run: | | ||
gh actions-cache --help | ||
- name: List Command | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} | ||
run: | | ||
cache_found=$(gh actions-cache list --key $CacheKey --limit 100 --branch $GITHUB_REF --order desc --sort created-at | grep $CacheKey) | ||
echo $cache_found | ||
[[ -z "$cache_found" ]] && exit 1 || echo "Cache List Successful" | ||
- name: Delete Command | ||
shell: bash | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REPO_WRITE_TOKEN }} | ||
run: | | ||
cache_delete=$(gh actions-cache delete $CacheKey --branch $GITHUB_REF --confirm | grep "Deleted 1 cache entry with key") | ||
echo $cache_delete | ||
[[ -z "$cache_delete" ]] && exit 1 || echo "Cache Delete Successful" | ||
- name: Slack Notification on failure | ||
if: failure() | ||
uses: 8398a7/action-slack@a74b761b4089b5d730d813fbedcd2ec5d394f3af | ||
with: | ||
text: actions/gh-actions-cache E2E test failure | ||
status: ${{ job.status }} | ||
fields: repo,workflow,message,author,action,ref | ||
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |