Build all micro/examples for release-X.X.X branches (#1683)
				
					
				
			* Build all the examples on push to any release branch
This commit is contained in:
		
							
								
								
									
										34
									
								
								.github/workflows/micro-examples.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								.github/workflows/micro-examples.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | |||||||
|  | name: Build all github.com/micro/examples | ||||||
|  | on: | ||||||
|  |   push:  | ||||||
|  |     branches: | ||||||
|  |       - 'release-**' | ||||||
|  |  | ||||||
|  | jobs: | ||||||
|  |  | ||||||
|  |   build: | ||||||
|  |     name: Build repos | ||||||
|  |     runs-on: ubuntu-latest | ||||||
|  |     steps: | ||||||
|  |  | ||||||
|  |     - name: Set up Go 1.13 | ||||||
|  |       uses: actions/setup-go@v1 | ||||||
|  |       with: | ||||||
|  |         go-version: 1.13 | ||||||
|  |       id: go | ||||||
|  |  | ||||||
|  |     - name: Check out this code | ||||||
|  |       uses: actions/checkout@v2 | ||||||
|  |       with: | ||||||
|  |         path: 'go-micro' | ||||||
|  |  | ||||||
|  |     - name: Check out code examples | ||||||
|  |       uses: actions/checkout@v2 | ||||||
|  |       with: | ||||||
|  |         repository: 'micro/examples' | ||||||
|  |         path: 'examples' | ||||||
|  |  | ||||||
|  |     - name: Build all | ||||||
|  |       run: $GITHUB_WORKSPACE/go-micro/.github/workflows/scripts/build-all-examples.sh $GITHUB_SHA | ||||||
|  |       working-directory: examples | ||||||
|  |      | ||||||
							
								
								
									
										43
									
								
								.github/workflows/scripts/build-all-examples.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							
							
						
						
									
										43
									
								
								.github/workflows/scripts/build-all-examples.sh
									
									
									
									
										vendored
									
									
										Executable file
									
								
							| @@ -0,0 +1,43 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | # set -x | ||||||
|  |  | ||||||
|  | function build_binary { | ||||||
|  |     echo building $1 | ||||||
|  |     pushd $1 | ||||||
|  |     go build | ||||||
|  |     local ret=$? | ||||||
|  |     if [ $ret -gt 0 ]; then  | ||||||
|  |         failed=1 | ||||||
|  |         failed_arr+=($1) | ||||||
|  |     fi | ||||||
|  |     popd | ||||||
|  | } | ||||||
|  |  | ||||||
|  | function is_main { | ||||||
|  |     grep "package main" -l -dskip $1/*.go > /dev/null 2>&1 | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | function check_dir { | ||||||
|  |     is_main $1 | ||||||
|  |     local ret=$? | ||||||
|  |     if [ $ret == 0 ]; then | ||||||
|  |         build_binary $1 $2 | ||||||
|  |     fi | ||||||
|  |     for filename in $1/*; do | ||||||
|  |         if [ -d $filename ]; then | ||||||
|  |             check_dir $filename $2 | ||||||
|  |         fi | ||||||
|  |     done | ||||||
|  | } | ||||||
|  | failed_arr=() | ||||||
|  | failed=0 | ||||||
|  | this_hash=$1 | ||||||
|  | go mod init github.com/micro/examples | ||||||
|  | go mod edit -require=github.com/micro/go-micro/v2@$1  | ||||||
|  | check_dir . $1 | ||||||
|  | if [ $failed -gt 0 ]; then | ||||||
|  |     echo Some builds failed | ||||||
|  |     printf '%s\n' "${failed_arr[@]}" | ||||||
|  | fi | ||||||
|  | exit $failed | ||||||
		Reference in New Issue
	
	Block a user