Skip to content

Commit

Permalink
WIP: Linux reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tundranerd committed Oct 28, 2023
1 parent 68b994c commit 080cf39
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 238 deletions.
239 changes: 7 additions & 232 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
on:
#schedule:
# - cron: '30 6 * * *' #0630 UTC kick off full build and regression
push:
branches: [ ci/* ]
workflow_dispatch:
Expand All @@ -10,234 +8,11 @@ on:
required: false
type: boolean
default: false
buildDocker:
description: "Build and deploy docker image?"
required: false
type: boolean
default: false

env:
AWS_REGION: us-east-1
AWS_SUBNET_ID: subnet-064f21b53fc72cf44
AWS_SG_ID: sg-0ca7912782cf1538b
AMI_ID: ami-0b0e38d12eb5ff011
AWS_INSTANCE_TYPE: c5a.8xlarge
AWS_AVAILABILITY_ZONE: us-east-1b
OS: linux
KEY_PAIR: win
jobs:
start-runner:
name: Start self-hosted EC2 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-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Start EC2 runner
id: start-ec2-runner
uses: tundranerd/ec2-multiple-github-runners@multi-os-multi-runner
with:
mode: start
key-pair: ${{ env.KEY_PAIR }}
os: ${{ env.OS }}
github-token: ${{ secrets.GH_TOKEN}}
ec2-image-id: ${{ env.AMI_ID}}
ec2-instance-type: ${{ env.AWS_INSTANCE_TYPE }}
subnet-id: ${{ env.AWS_SUBNET_ID }}
security-group-id: ${{ env.AWS_SG_ID }}
availability-zone: ${{ env.AWS_AVAILABILITY_ZONE }}
wait-for-registry-timeout: 5
aws-resource-tags: > # optional, requires additional permissions
[
{"Key": "Name", "Value": "ec2-github-runner"},
{"Key": "GitHubRepository", "Value": "${{ github.repository }}"},
{"Key": "os", "Value": "${{ env.OS }}"}
]
build:
name: Clone and build
needs:
- start-runner # required to get output from the start-runner job
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
outputs:
git_describe: ${{ steps.git-describe.outputs.git_describe }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: git-describe
run: |
echo "git_describe=$(git describe --tags)" >> "$GITHUB_OUTPUT"
- name: Build
run: |
ci/linux/build.sh
- name: Create SDK
run: |
ci/linux/create-febio-sdk.sh
- name: Upload SDK
uses: actions/upload-artifact@v3
with:
name: febio4-sdk-${{runner.os}}-${{runner.arch}}
path: |
febio-sdk
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: febio4-${{runner.os}}-${{runner.arch}}
path: |
cmbuild/bin
cmbuild/lib
!cmbuild/lib/*.a
tests:
if: ${{inputs.runTests}}
name: Run test suite
needs:
- start-runner # required to get output from the start-runner job
- build
runs-on: ${{ needs.start-runner.outputs.label }} # run the job on the newly created runner
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/download-artifact@v3
with:
name: febio4-${{runner.os}}-${{runner.arch}}
path: |
cmbuild
- name: Run test suite
run: |
ci/linux/test.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: testsuite-${{runner.os}}-${{runner.arch}}-logs
path: |
TestSuite/Verify3/*.log
TestSuite/Logs*.txt
stop-runner:
name: Stop self-hosted EC2 runner
needs:
- start-runner # required to get output from the start-runner job
- tests # required to wait when the main job is done
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Stop EC2 runner
uses: tundranerd/ec2-multiple-github-runners@multi-os-multi-runner
with:
mode: stop
os: ${{ env.OS }}
wait-for-deregistry-timeout: 5
github-token: ${{ secrets.GH_TOKEN}}
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
repo-artifacts:
name: Upload artifacts to repo
needs:
- build # required to get output from the start-runner job
runs-on: ubuntu-latest
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- uses: actions/download-artifact@v3
with:
name: febio4-${{runner.os}}-${{runner.arch}}
path: |
cmbuild
- name: Configure SSH
run: |
ci/common/linux/configure-ssh.sh
env:
SSH_USER: ${{ secrets.REPO_USER }}
SSH_KEY: ${{ secrets.REPO_KEY }}
SSH_HOST: ${{ secrets.REPO_HOST }}
- name: Stage Build to Repo
run: |
ci/linux/scp-to-repo.sh
- name: Make Dev Release
run: |
ssh repo "python3 update2/FEBioStudio2Dev/makeDevRelease.py -l"
publish-to-s3:
name: Publish to S3
needs:
- build
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: 'true'
- name: Download SDK
uses: actions/download-artifact@v3
with:
name: febio4-sdk-${{runner.os}}-${{runner.arch}}
path: |
artifacts/febio-sdk
- name: Download febio
uses: actions/download-artifact@v3
with:
name: febio4-${{runner.os}}-${{runner.arch}}
path: |
artifacts/febio
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Publish to S3
env:
BUCKET_NAME: febio-packages
OS: ${{ env.os }}
REF_NAME: ${{ github.ref_name}}
PACKAGE_NAME: febio
GIT_TAG: ${{ needs.build.outputs.git_describe }}
run: |
ci/linux/publish-to-s3.sh
docker:
name: Build and deploy docker with latest
needs:
- build # required to get output from the start-runner job
runs-on: ubuntu-latest
if: ${{inputs.buildDocker}}
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: febio4-${{runner.os}}-${{runner.arch}}
path: |
cmbuild
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
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: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push docker image to Amazon ECR
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: febio-runtime
IMAGE_TAG: ${{ needs.build.outputs.git_describe }}
run: |
ci/linux/publish-docker-images.sh
call_workflow:
uses: febiosoftware/febio-workflows/.github/workflows/linux-reusable.yml@reusable-worfklow-linux
with:
runTests: ${{ inputs.runTests && true || false }}
package-name: febio4
package-sdk: true
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
on:
#schedule:
# - cron: '00 7 * * *' #0630 UTC kick off full build and regression
push:
branches: [ ci/* ]
# push:
# branches: [ ci/* ]
workflow_dispatch:
inputs:
runTests:
Expand Down
10 changes: 6 additions & 4 deletions ci/Linux/create-febio-sdk.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#! /bin/bash
mkdir -p febio-sdk/{include,lib,bin}
find . -name "*.h*" -type f -exec cp --parents -a {} ./febio-sdk/include/ \;
find cmbuild/lib -name "*" -type f -exec cp -a {} ./febio-sdk/lib/ \;
find cmbuild/bin -name "*" -type f -exec cp -a {} ./febio-sdk/bin/ \;
TARGET_DIR="${TARGET_DIR:-febio4-sdk}"
mkdir -p ${TARGET_DIR}/{include,lib,bin}
# Gotta use rsync macos cp doesn't support --parent
find . -name "*.h*" -type f -not -path "./infrastructure/*" -not -path "./${TARGET_DIR}/*" -exec rsync -R -dir {} "./${TARGET_DIR}/include/" \;
find cmbuild/lib -name "*" -type f -exec cp -a {} "./${TARGET_DIR}/lib/" \;
find cmbuild/bin -name "*" -type f -exec cp -a {} "./${TARGET_DIR}/bin/" \;

0 comments on commit 080cf39

Please sign in to comment.