Skip to content

Commit

Permalink
Use testing repo actions
Browse files Browse the repository at this point in the history
  • Loading branch information
b-chu committed Feb 13, 2024
1 parent 7fdce54 commit 7c9390a
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 101 deletions.
47 changes: 15 additions & 32 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,19 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a
# config file.
# By default, queries listed here will override any specified in a
# config file.
# Prefix the list here with "+" to use these queries and those in the
# config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually
# (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following
# three lines and modify them (or add more) to build your code if your
# project uses a compiled language

# - run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: cicd
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/codeql-analysis
with:
language: ${{ matrix.language }}
32 changes: 15 additions & 17 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
pip install coverage[toml]==6.5.0
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
path: ${{ inputs.download-path }}
- name: Generate coverage report
run: |
set -ex
# Flatten the coverage files
ls ${{ inputs.download-path }} | while read x; do mv ${{ inputs.download-path }}/$x/.coverage .coverage.$x; done
python -m coverage combine
python -m coverage report
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: cicd
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/coverage
with:
download-path: ${{ inputs.download-path }}
81 changes: 33 additions & 48 deletions .github/workflows/docker-configure-build-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,62 +34,47 @@ on:
required: true
password:
required: true
app_id:
required: true
private_key:
required: true
jobs:
configure-build-push:
runs-on: ubuntu-latest
steps:
- name: Maximize Build Space on Worker
uses: easimon/maximize-build-space@v4
with:
overprovision-lvm: true
remove-dotnet: true
remove-android: true
remove-haskell: true

- name: Checkout
uses: actions/checkout@v3

- name: Setup QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
username: ${{ secrets.username }}
password: ${{ secrets.password }}

- name: Calculate Docker Image Variables
app_id: ${{ secrets.app_id }}
private_key: ${{ secrets.private_key }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: cicd
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- name: List files
run: |
set -euo pipefail
###################
# Calculate the tag
###################
if [ "${{ inputs.staging }}" = "true" ]; then
STAGING_REPO=${{ inputs.staging-repo }}
IMAGE_TAG=${STAGING_REPO}:${{ inputs.image-uuid }}
IMAGE_CACHE="${STAGING_REPO}:${{ inputs.image-name }}-buildcache"
else
IMAGE_TAG=${{ inputs.tags }}
IMAGE_CACHE="${IMAGE_TAG/,*/}-buildcache"
fi
echo "IMAGE_TAG=${IMAGE_TAG}" >> ${GITHUB_ENV}
echo "IMAGE_CACHE=${IMAGE_CACHE}" >> ${GITHUB_ENV}
- name: IMAGE_TAG = ${{ env.IMAGE_TAG }}
run: echo ${{ env.IMAGE_TAG }}

- name: Build and Push the Docker Image
uses: docker/build-push-action@v3
pwd
ls -d $PWD/*
ls -d $PWD/*/testing
ls -d $PWD/*/testing/.github
ls -d $PWD/*/testing/.github/actions
ls -d $PWD/*/testing/.github/actions/docker-configure-build-push
- uses: ./testing/.github/actions/docker-configure-build-push
with:
build-args: ${{ inputs.build-args }}
context: ${{ inputs.context }}
tags: ${{ env.IMAGE_TAG }}
target: ${{ inputs.target }}
image-name: ${{ inputs.image-name }}
image-uuid: ${{ inputs.image-uuid }}
push: ${{ inputs.push }}
cache-from: type=registry,ref=${{ env.IMAGE_CACHE }}
cache-to: type=registry,ref=${{ env.IMAGE_CACHE }},mode=max
build-args: ${{ inputs.build-args }}
staging: ${{ inputs.staging }}
staging-repo: ${{ inputs.staging-repo }}
tags: ${{ inputs.tags }}
target: ${{ inputs.target }}
username: ${{ secrets.username }}
password: ${{ secrets.password }}
26 changes: 22 additions & 4 deletions .github/workflows/pr-code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
jobs:
code-quality:
uses: ./.github/workflows/code-quality.yaml
runs-on: ubuntu-20.04
timeout-minutes: 15
strategy:
matrix:
python_version:
Expand All @@ -23,6 +24,23 @@ jobs:
- "3.11"
pip_deps:
- "[dev]"
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get Repo Token
id: REPO_TOKEN
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
- name: Get composite run steps repository
uses: actions/checkout@v3
with:
repository: mosaicml/testing
ref: cicd
path: ./testing
token: ${{ steps.REPO_TOKEN.outputs.token }}
- uses: ./testing/.github/actions/code-quality
with:
python_version: ${{ matrix.python_version }}
pip_deps: ${{ matrix.pip_deps }}
2 changes: 2 additions & 0 deletions .github/workflows/pr-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ jobs:
secrets:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
2 changes: 2 additions & 0 deletions .github/workflows/release-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ jobs:
secrets:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
app_id: ${{ secrets.DEVOGE_BOT_PUB_APPID }}
private_key: ${{ secrets.DEVOGE_BOT_PUB_PEM }}
9 changes: 9 additions & 0 deletions .spr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
githubRepoOwner: mosaicml
githubRepoName: composer
githubRemote: upstream
githubBranch: dev
mergeMethod: squash
prTemplatePath: .github/PULL_REQUEST_TEMPLATE.md
prTemplateInsertStart: "# What does this PR do?"
prTemplateInsertEnd: "# What issue(s) does this change relate to?"

0 comments on commit 7c9390a

Please sign in to comment.