Skip to content

Commit

Permalink
test 3
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
  • Loading branch information
Ansuel committed Oct 26, 2023
1 parent 96101fb commit e116d71
Show file tree
Hide file tree
Showing 2 changed files with 284 additions and 30 deletions.
154 changes: 124 additions & 30 deletions .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,135 @@ on:
- master

jobs:
determine_targets:
name: Set targets
runs-on: ubuntu-latest
outputs:
targets_subtargets: ${{ steps.find_targets.outputs.targets_subtargets }}
targets: ${{ steps.find_targets.outputs.targets }}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35

- name: Set targets
id: find_targets
run: |
ALL_TARGETS="$(perl ./scripts/dump-target-info.pl targets 2>/dev/null)"
CHANGED_FILES="$(echo ${{ steps.changed-files.outputs.all_changed_files }} | tr ' ' '\n')"
TARGETS_SUBTARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1 | awk '{ print $1 }')"
TARGETS="$(echo "$ALL_TARGETS" | sort -u -t '/' -k1,1 | awk '{ print $1 }')"
# On testing non-specific target, skip testing each subtarget if we are testing pr
if [ ${{ github.event_name }} != 'push' ]; then
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic; then
TARGETS_SUBTARGETS=$TARGETS
fi
fi
JSON_TARGETS_SUBTARGETS='['
FIRST=1
for TARGET in $TARGETS_SUBTARGETS; do
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic ||
echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"','
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS""$TUPLE"
FIRST=0
fi
done
JSON_TARGETS_SUBTARGETS="$JSON_TARGETS_SUBTARGETS"']'
JSON_TARGETS='['
FIRST=1
for TARGET in $TARGETS; do
if echo "$CHANGED_FILES" | grep -v -q target/linux ||
echo "$CHANGED_FILES" | grep -q target/linux/generic ||
echo "$CHANGED_FILES" | grep -q $(echo $TARGET | cut -d "/" -f 1); then
TUPLE='{"target":"'"$(echo $TARGET | cut -d "/" -f 1)"'","subtarget":"'"$(echo $TARGET | cut -d "/" -f 2)"'"}'
[[ $FIRST -ne 1 ]] && JSON_TARGETS="$JSON_TARGETS"','
JSON_TARGETS="$JSON_TARGETS""$TUPLE"
FIRST=0
fi
done
JSON_TARGETS="$JSON_TARGETS"']'
echo -e "\n---- targets to build ----\n"
echo "$JSON_TARGETS_SUBTARGETS"
echo -e "\n---- targets to build ----\n"
echo -e "\n---- targets to check patch ----\n"
echo "$JSON_TARGETS"
echo -e "\n---- targets to check patch ----\n"
echo "targets_subtargets=$JSON_TARGETS_SUBTARGETS" >> $GITHUB_OUTPUT
echo "targets=$JSON_TARGETS" >> $GITHUB_OUTPUT
build:
name: Build Kernel with external toolchain
needs: determine_targets
permissions:
contents: read
packages: read
actions: write
strategy:
fail-fast: False
matrix:
include: "${{fromJson(needs.determine_targets.outputs.targets_subtargets)}}"
uses: ./.github/workflows/test-macos2.yml
with:
container_name: toolchain
target: ${{ matrix.target }}
subtarget: ${{ matrix.subtarget }}
build_kernel: true
build_all_kmods: true
upload_ccache_cache: ${{ github.repository_owner == 'openwrt' }}

build2:
name: Build armsr/armv8
runs-on: macos-latest
runs-on: ubuntu-latest
needs: build

steps:
- name: Determine base branch tag
id: determine_base_branch
run: |
BASE_BRANCH=openwrt-23.05
# if [ -n "${{ github.base_ref }}" ]; then
# if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
# BASE_BRANCH="${{ github.base_ref }}"
# fi
# elif [ ${{ github.ref_type }} == "branch" ]; then
# if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
# CONTAINER_TAG=${{ github.ref_name }}
# elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
# BASE_BRANCH="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
# fi
# elif [ ${{ github.ref_type }} == "tag" ]; then
# if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
# BASE_BRANCH=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
# fi
# fi
echo "Detected base branch as $BASE_BRANCH"
echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
- name:
env:
TEST: ${{ steps.determine_base_branch.outputs.base_branch != 'main' && \
steps.determine_base_branch.outputs.base_branch || '' }}
run: |
# - name: Determine base branch tag
# id: determine_base_branch
# run: |
# BASE_BRANCH=openwrt-23.05
# # if [ -n "${{ github.base_ref }}" ]; then
# # if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
# # BASE_BRANCH="${{ github.base_ref }}"
# # fi
# # elif [ ${{ github.ref_type }} == "branch" ]; then
# # if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
# # CONTAINER_TAG=${{ github.ref_name }}
# # elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
# # BASE_BRANCH="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
# # fi
# # elif [ ${{ github.ref_type }} == "tag" ]; then
# # if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
# # BASE_BRANCH=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
# # fi
# # fi

echo ${{env.TEST}}
# echo "Detected base branch as $BASE_BRANCH"
# echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPU

- name: aaa
# env:
# TEST: ${{ steps.determine_base_branch.outputs.base_branch != 'main' &&
# steps.determine_base_branch.outputs.base_branch || '' }}
shell: sh
run: |
echo ${{ needs.build.outputs.ccache_tag }}
# - name: Checkout master directory
# uses: actions/checkout@v3
# with:
Expand Down
160 changes: 160 additions & 0 deletions .github/workflows/test-macos2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: Build sub target

on:
workflow_call:
secrets:
coverity_api_token:
inputs:
container_name:
type: string
default: tools
target:
required: true
type: string
subtarget:
required: true
type: string
testing:
type: boolean
build_toolchain:
type: boolean
include_feeds:
type: boolean
build_full:
type: boolean
build_kernel:
type: boolean
build_all_modules:
type: boolean
build_all_kmods:
type: boolean
build_all_boards:
type: boolean
use_openwrt_container:
type: boolean
default: true
coverity_project_name:
type: string
default: OpenWrt
coverity_check_packages:
type: string
coverity_compiler_template_list:
type: string
default: >-
arm-openwrt-linux-gcc
coverity_force_compile_packages:
type: string
default: >-
curl
libnl
mbedtls
wolfssl
openssl
build_external_toolchain:
type: boolean
upload_external_toolchain:
type: boolean
use_ccache_cache:
type: boolean
default: true
ccache_type:
type: string
default: kernel
upload_ccache_cache:
type: boolean
check:
type: boolean
default: true

permissions:
contents: read

jobs:
setup_build:
name: Setup build ${{ inputs.target }}/${{ inputs.subtarget }}
runs-on: ubuntu-latest
outputs:
container: ${{ steps.determine_container.outputs.container }}
ccache_tag: ${{ steps.determine_ccache_tag.outputs.ccache_tag }}
ccache_name: ${{ steps.determine_ccache_name.outputs.ccache_name }}

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set lower case owner name
id: lower_owner
run: |
OWNER_LC=$(echo "${{ github.repository_owner }}" \
| tr '[:upper:]' '[:lower:]')
if [ ${{ inputs.use_openwrt_container }} == "true" ]; then
OWNER_LC=openwrt
fi
echo "owner_lc=$OWNER_LC" >> $GITHUB_OUTPUT
- name: Determine base branch tag
id: determine_base_branch
run: |
BASE_BRANCH=main
if [ -n "${{ github.base_ref }}" ]; then
if echo "${{ github.base_ref }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
BASE_BRANCH="${{ github.base_ref }}"
fi
elif [ ${{ github.ref_type }} == "branch" ]; then
if echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]$'; then
BASE_BRANCH=${{ github.ref_name }}
elif echo "${{ github.ref_name }}" | grep -q -E '^openwrt-[0-9][0-9]\.[0-9][0-9]-'; then
BASE_BRANCH="$(echo ${{ github.ref_name }} | sed 's/^\(openwrt-[0-9][0-9]\.[0-9][0-9]\)-.*/\1/')"
fi
elif [ ${{ github.ref_type }} == "tag" ]; then
if echo "${{ github.ref_name }}" | grep -q -E '^v[0-9][0-9]\.[0-9][0-9]\..+'; then
BASE_BRANCH=openwrt-"$(echo ${{ github.ref_name }} | sed 's/^v\([0-9][0-9]\.[0-9][0-9]\)\..\+/\1/')"
fi
fi
echo "Detected base branch as $BASE_BRANCH"
echo "base_branch=$BASE_BRANCH" >> $GITHUB_OUTPUT
# Per branch tools container tag
# By default stick to latest
# For official test targetting openwrt stable branch
# Get the branch or parse the tag and push dedicated tools containers
# For local test to use the correct container for stable release testing
# you need to use for the branch name a prefix of openwrt-[0-9][0-9].[0-9][0-9]-
- name: Determine container name
id: determine_container_name
env:
CONTAINER_TAG: ${{ steps.determine_base_branch.outputs.base_branch != 'main' && steps.determine_base_branch.outputs.base_branch || 'latest' }}
run: |
CONTAINER_NAME=${{ inputs.container_name }}
CONTAINER_TAG=${{ env.CONTAINER_TAG }}
if [ "$CONTAINER_NAME" = "toolchain" ]; then
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
GHCR_HEADER="Authorization: Bearer ${GHCR_TOKEN}"
GHCR_MANIFEST_LINK=https://ghcr.io/v2/${{ steps.lower_owner.outputs.owner_lc }}/${{ inputs.container_name }}/manifests/${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
# Check if container exist
if [ $(curl -s -o /dev/null -w "%{http_code}" -H "$GHCR_HEADER" -I "$GHCR_MANIFEST_LINK") = 200 ]; then
CONTAINER_TAG=${{ inputs.target }}-${{ inputs.subtarget }}-"$CONTAINER_TAG"
else
CONTAINER_NAME=tools
fi
fi
echo "Tools container to use $CONTAINER_NAME:$CONTAINER_TAG"
echo "container_name=$CONTAINER_NAME:$CONTAINER_TAG" >> $GITHUB_OUTPUT
- name: Determine container
id: determine_container
run: echo "container=${{ steps.lower_owner.outputs.owner_lc }}/${{ steps.determine_container_name.outputs.container_name }}" >> $GITHUB_OUTPUT

- name: Determine ccache tag
id: determine_ccache_tag
if: steps.determine_base_branch.outputs.base_branch != 'main'
run: echo "ccache_tag=${{ format('-{0}', steps.determine_base_branch.outputs.base_branch) }}" >> $GITHUB_OUTPUT

- name: Determine ccache name
id: determine_ccache_name
run: echo "ccache_name=ccache-${{ inputs.ccache_type }}-${{ inputs.target }}-${{ inputs.subtarget }}${{ steps.determine_ccache_tag.outputs.ccache_tag }}" >> $GITHUB_OUTPUT

0 comments on commit e116d71

Please sign in to comment.