From 9805f5f135bbbdd6149565d38cb16e7890fc85ce Mon Sep 17 00:00:00 2001 From: Chenlong Ma Date: Tue, 17 Jan 2023 13:22:36 +0800 Subject: [PATCH] Create workflows Signed-off-by: Chenlong Ma --- .github/workflows/CodeQL.yml | 72 +++++++++++++++++++ .github/workflows/check-crlf.yaml | 14 ++++ .../fedlcm-docker-build-and-push.yaml | 50 +++++++++++++ .github/workflows/fedlcm-unit-test.yaml | 25 +++++++ .../fml-manager-docker-build-and push.yaml | 52 ++++++++++++++ .github/workflows/fml-manager-unit-test.yaml | 26 +++++++ .../site-portal-docker-build-and-push.yaml | 52 ++++++++++++++ .github/workflows/site-portal-unit-test.yaml | 26 +++++++ 8 files changed, 317 insertions(+) create mode 100644 .github/workflows/CodeQL.yml create mode 100644 .github/workflows/check-crlf.yaml create mode 100644 .github/workflows/fedlcm-docker-build-and-push.yaml create mode 100644 .github/workflows/fedlcm-unit-test.yaml create mode 100644 .github/workflows/fml-manager-docker-build-and push.yaml create mode 100644 .github/workflows/fml-manager-unit-test.yaml create mode 100644 .github/workflows/site-portal-docker-build-and-push.yaml create mode 100644 .github/workflows/site-portal-unit-test.yaml diff --git a/.github/workflows/CodeQL.yml b/.github/workflows/CodeQL.yml new file mode 100644 index 0000000..e8fb4c0 --- /dev/null +++ b/.github/workflows/CodeQL.yml @@ -0,0 +1,72 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + workflow_dispatch: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go', 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + 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. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # 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. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/check-crlf.yaml b/.github/workflows/check-crlf.yaml new file mode 100644 index 0000000..8f2abbc --- /dev/null +++ b/.github/workflows/check-crlf.yaml @@ -0,0 +1,14 @@ +name: Check CRLF + +on: pull_request + +jobs: + check-CRLF: + name: Check CRLF action + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + + - name: check-crlf + uses: erclu/check-crlf@v1 \ No newline at end of file diff --git a/.github/workflows/fedlcm-docker-build-and-push.yaml b/.github/workflows/fedlcm-docker-build-and-push.yaml new file mode 100644 index 0000000..957f4a7 --- /dev/null +++ b/.github/workflows/fedlcm-docker-build-and-push.yaml @@ -0,0 +1,50 @@ +name: FedLCM docker build and push + +on: + push: + # Publish `main` as Docker `latest` image. + branches: + - main + + # Publish `v1.2.3` tags as releases. + tags: + - v* + +jobs: + # no test is required + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@main + + - name: Prepare the TAG + id: prepare-the-tag + run: | + # strip git ref prefix from version + TAG="" + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + if [ $VERSION = "main" ]; then + TAG="latest" + fi + echo "TAG=${TAG}" + echo "TAG=${TAG}" >> $GITHUB_OUTPUT + - name: Build image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + make docker-build + + - name: Log into DockerHub + run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + make docker-push diff --git a/.github/workflows/fedlcm-unit-test.yaml b/.github/workflows/fedlcm-unit-test.yaml new file mode 100644 index 0000000..f345c84 --- /dev/null +++ b/.github/workflows/fedlcm-unit-test.yaml @@ -0,0 +1,25 @@ +name: FedLCM server unit test + +on: + pull_request: + paths: + - ".github/workflows/fedlcm-unit-test.yaml" + - "server/*" + - “pkg/*” +jobs: + Unit-test: + name: Unit Test + runs-on: ubuntu-latest + steps: + - name: Setup + uses: actions/setup-go@v1 + with: + go-version: 1.19 + id: go + + - name: Code + uses: actions/checkout@main + + - name: Unit Test + run: | + make server-unittest \ No newline at end of file diff --git a/.github/workflows/fml-manager-docker-build-and push.yaml b/.github/workflows/fml-manager-docker-build-and push.yaml new file mode 100644 index 0000000..4a58ee6 --- /dev/null +++ b/.github/workflows/fml-manager-docker-build-and push.yaml @@ -0,0 +1,52 @@ +name: FML-Manager docker build and push + +on: + push: + # Publish `main` as Docker `latest` image. + branches: + - main + + # Publish `v1.2.3` tags as releases. + tags: + - v* + +jobs: + # no test is required + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@main + + - name: Prepare the TAG + id: prepare-the-tag + run: | + # strip git ref prefix from version + TAG="" + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + if [ $VERSION = "main" ]; then + TAG="latest" + fi + echo "TAG=${TAG}" + echo "TAG=${TAG}" >> $GITHUB_OUTPUT + - name: Build image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + cd fml-manager + make docker-build + + - name: Log into DockerHub + run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + cd fml-manager + make docker-push diff --git a/.github/workflows/fml-manager-unit-test.yaml b/.github/workflows/fml-manager-unit-test.yaml new file mode 100644 index 0000000..fcbc456 --- /dev/null +++ b/.github/workflows/fml-manager-unit-test.yaml @@ -0,0 +1,26 @@ +name: FML-Manager server unit test + +on: + pull_request: + paths: + - ".github/workflows/fml-manager-unit-test.yaml" + - "fml-manager/server/*" + +jobs: + Unit-test: + name: Unit Test + runs-on: ubuntu-latest + steps: + - name: Setup + uses: actions/setup-go@v1 + with: + go-version: 1.19 + id: go + + - name: Code + uses: actions/checkout@main + + - name: Unit Test + run: | + cd fml-manager + make server-unittest \ No newline at end of file diff --git a/.github/workflows/site-portal-docker-build-and-push.yaml b/.github/workflows/site-portal-docker-build-and-push.yaml new file mode 100644 index 0000000..443566d --- /dev/null +++ b/.github/workflows/site-portal-docker-build-and-push.yaml @@ -0,0 +1,52 @@ +name: Site-Portal docker build and push + +on: + push: + # Publish `main` as Docker `latest` image. + branches: + - main + + # Publish `v1.2.3` tags as releases. + tags: + - v* + +jobs: + # no test is required + push: + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@main + + - name: Prepare the TAG + id: prepare-the-tag + run: | + # strip git ref prefix from version + TAG="" + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + if [ $VERSION = "main" ]; then + TAG="latest" + fi + echo "TAG=${TAG}" + echo "TAG=${TAG}" >> $GITHUB_OUTPUT + - name: Build image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + cd site-portal + make docker-build + + - name: Log into DockerHub + run: docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push image + run: | + TAG=${{steps.prepare-the-tag.outputs.TAG}} + if [ ! -z "$TAG" ]; then + export TAG=$TAG + fi + cd site-portal + make docker-push diff --git a/.github/workflows/site-portal-unit-test.yaml b/.github/workflows/site-portal-unit-test.yaml new file mode 100644 index 0000000..2eec508 --- /dev/null +++ b/.github/workflows/site-portal-unit-test.yaml @@ -0,0 +1,26 @@ +name: Site-Portal server unit test + +on: + pull_request: + paths: + - ".github/workflows/site-portal-unit-test.yaml" + - "site-portal/server/*" + +jobs: + Unit-test: + name: Unit Test + runs-on: ubuntu-latest + steps: + - name: Setup + uses: actions/setup-go@v1 + with: + go-version: 1.19 + id: go + + - name: Code + uses: actions/checkout@main + + - name: Unit Test + run: | + cd site-portal + make server-unittest \ No newline at end of file