Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github Actions CI Changes #187

Merged
merged 23 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Created reusable workflows
External call to code.yml make_boot job
  • Loading branch information
shihab-dls authored and tomtrafford committed Oct 4, 2024
commit f6ab6c8e0c050ee8514ba5c8079ef1feaddb9096
46 changes: 46 additions & 0 deletions .github/workflows/_make_boot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
on:
workflow_call:

jobs:
make_boot:
strategy:
fail-fast: false
matrix:
include:
- platform: zynq
app: PandABox-no-fmc
- platform: zynqmp
app: xu5_st1-no-fmc
runs-on: ubuntu-latest

steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run Composite
uses: ./.github/actions/setupenv
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Mount in rclone bucket from runner into conatiner
- name: make boot
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make boot APP_NAME=${{ matrix.app }}"

# Artifacts
- name: Upload boot
uses: actions/upload-artifact@v2
with:
name: zpkgs
path: ./build/boot*.zip
49 changes: 49 additions & 0 deletions .github/workflows/_make_zpkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
on:
workflow_call:


jobs:
make_zpkg:
strategy:
fail-fast: false
matrix:
app: [
"PandABox-no-fmc",
"PandABox-fmc_24vio",
"PandABox-fmc_acq427",
"PandABox-fmc_acq430",
"PandABox-fmc_lback-sfp_lback",
"ZedBoard-no-fmc",
]
runs-on: ubuntu-latest
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run Composite
uses: ./.github/actions/setupenv
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Mount in rclone bucket from runner into conatiner
- name: build carrier_ip and zpkg
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make carrier_ip APP_NAME=${{ matrix.app }} && make zpkg APP_NAME=${{ matrix.app }} "

# Artifacts
- name: Upload zpkg
uses: actions/upload-artifact@v2
with:
name: zpkgs
path: ./build/panda-fpga@*.zpg
43 changes: 43 additions & 0 deletions .github/workflows/_make_zpkg_aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
on:
workflow_call:

jobs:
make_zpkg_aws:
strategy:
fail-fast: false
matrix:
app:
["xu5_st1-no-fmc","xu5_st1-fmc_acq430"]
name: make zpkg on aws
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run Composite
uses: ./.github/actions/setupenv
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Mount in rclone bucket from vm into conatiner
- name: build carrier_ip and zpkg
run: |
sudo docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
sudo docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest\
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make carrier_ip APP_NAME=${{ matrix.app }} && make zpkg APP_NAME=${{ matrix.app }}"

# Artifacts
- name: Upload zpkg
uses: actions/upload-artifact@v2
with:
name: zpkgs
path: ./build/panda-fpga@*.zpg
24 changes: 24 additions & 0 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
workflow_call:

jobs:
release:
runs-on: ubuntu-latest
# make a release on every tag
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v2
with:
name: zpkgs
path: zpkgs

- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@2d72d869af3bf23602f9593a1e3fd739b80ac1eb # v0.1.12
with:
prerelease: ${{ contains(github.ref_name, 'a') || contains(github.ref_name, 'b') || contains(github.ref_name, 'rc') }}
files: zpkgs/*
body: See [Changelog](CHANGELOG.rst) for more details
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .github/workflows/_setup_aws_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on:
workflow_call:

jobs:
# Build rclone and mount S3 bucket
setup_aws_runner:
name: setup rclone and mount on runner
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run Composite
uses: ./.github/actions/setupenv
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
35 changes: 35 additions & 0 deletions .github/workflows/_start_aws_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
on:
workflow_call:

# Seting up AWS runners for high memory apps
jobs:
start-runner:
name: Start self hosted aws runner
runs-on: ubuntu-latest
outputs:
label: ${{ steps.start-ec2-runner.outputs.label }}
ec2-instance-id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
steps:

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Start EC2 runner
id: start-ec2-runner
uses: machulav/ec2-github-runner@v2
with:
mode: start
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
ec2-image-id: ${{ secrets.AWS_AMI_ID }}
ec2-instance-type: t3.xlarge
subnet-id: ${{ secrets.AWS_SUBNET_ID }}
security-group-id: ${{ secrets.AWS_SECURITY_GROUP_ID }}
aws-resource-tags: >
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"}
]
24 changes: 24 additions & 0 deletions .github/workflows/_stop_runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
workflow_call:

jobs:
stop-runner:
name: Stop self hosted EC2 runnner
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Stop EC2 runner
uses: machulav/ec2-github-runner@v2
continue-on-error: true
with:
mode: stop
github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
31 changes: 31 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
on:
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
steps:
# Git repositories
- name: Checkout Source
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Run Composite
uses: ./.github/actions/setupenv
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Run tests
- name: Make python and hdl tests
run: |
docker pull ghcr.io/pandablocks/pandablocks-dev-container:latest
docker run \
-v "${{ github.workspace }}:/repos" \
-v "${{ github.workspace }}/build:/build" \
-v "/scratch/Xilinx:/scratch/Xilinx" \
ghcr.io/pandablocks/pandablocks-dev-container:latest \
/bin/bash -c \
"cd PandABlocks-fpga && ln -s CONFIG.example CONFIG && make python_tests && make python_timing && \
make autogen && make hdl_test"
19 changes: 19 additions & 0 deletions .github/workflows/_undo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on:
workflow_call:

jobs:
undo:
runs-on: ubuntu-latest
if: ${{ always() && failure() && github.event_name == 'push' && contains(github.event.head_commit.message,'undo_true')}}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0
- name: Revert pushed commit
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git revert -m 1 --no-edit HEAD
git push