Skip to content

Deploy Test Crawler #71417

Deploy Test Crawler

Deploy Test Crawler #71417

name: Deploy Test Crawler
on:
schedule:
- cron: "*/10 * * * *"
jobs:
get-push-date:
runs-on: ubuntu-latest
outputs:
isPushed: ${{ steps.git-check.outputs.pushed}}
steps:
# Checkout the repository.
- name: Checkout the repository
uses: actions/checkout@v3
# Create date variable
- name: Create Date Variable
id: get-date
run: echo "::set-output name=date::$(date "+%s")"
# Cache .txt file and use date as dependancy to create new cache
- name: Store/Restore file in cache
id: cachedFile
uses: actions/cache@v3
with:
path: filecoin-lotus-latest-push-date.txt
key: ${{ runner.os }}-lotus-date-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-lotus-date
${{ runner.os }}-
# Create .txt file if it doesn't exist
- name: Create .txt file if it doesn't exist
if: hashFiles('filecoin-lotus-latest-push-date.txt') == ''
run: echo "initialDate" >> filecoin-lotus-latest-push-date.txt
# Get pushed_at value from github api https://api.github.com/repos/filecoin-project/lotus
- name: Fetch latest push
id: filecoin-lotus
run: |
echo ::set-output name=push_tag::$(curl -sL https://api.github.com/repos/filecoin-project/lotus | jq -r ".pushed_at")
echo ::set-output name=current_tag::$(cat filecoin-lotus-latest-push-date.txt)
# Update .txt file with latest pushed_at value if needed
- name: Check if new push
id: git-check
if: steps.filecoin-lotus.outputs.current_tag != steps.filecoin-lotus.outputs.push_tag
run: echo "::set-output name=pushed::true" && truncate -s 0 filecoin-lotus-latest-push-date.txt && echo ${{steps.filecoin-lotus.outputs.push_tag}} >> filecoin-lotus-latest-push-date.txt && cat filecoin-lotus-latest-push-date.txt;
run-test-crawler:
needs: [get-push-date]
runs-on: ubuntu-latest
if: needs.get-push-date.outputs.isPushed == 'true'
steps:
# Checkout the repository.
- name: Checkout the repository
uses: actions/checkout@v3
with:
token: ${{ secrets.GH_TOKEN }}
id: checkout
# Check if tests.json exists
- name: Check if tests.json file exists
id: is_existing
if: hashFiles('frontend/apps/web/src/tests.json') == ''
run: echo "::set-output name=tests_exist::false"
# Move uniqueREADME because it gets deleted when cloning repo
- name: Move readme file
run: mv repo-to-crawl/uniqueREADME.md ./
# Clone lotus repo into repo-to-crawl folder
- name: Clone lotus repo
uses: actions/checkout@v3
with:
repository: filecoin-project/lotus
path: repo-to-crawl
# Install go lang
- name: Install go lang 1.17.7
uses: actions/setup-go@v4
with:
go-version: "^1.17.7"
# Run test crawler
- name: Make run
run: make run || make run || make run
working-directory: test-crawler
# Copy crawler output
- name: Copy output
run: make copy-output
working-directory: test-crawler
# Delete cloned repo
- name: Delete cloned repo
run: find . -delete
working-directory: repo-to-crawl
# Move back uniqueREADME
- name: Move readme file back
run: mv uniqueREADME.md repo-to-crawl
# Create Pull Request for this action
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v3
# with:
# base: main
# branch: chore/generate-tests
# commit-message: Update tests.json
# title: "chore(test-crawler): Update tests.json"
# delete-branch: true
# Check if there are any changes
- name: Check if there are any changes
id: verify_diff
run: git diff --quiet || echo "::set-output name=new_tests::true"
# Commit changes
- name: Git identity and commit
if: steps.verify_diff.outputs.new_tests == 'true' || steps.is_existing.outputs.tests_exist == 'false'
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_ACTOR: ${{ github.actor }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '42103905+github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "chore: update tests.json"
git push