Skip to content

Commit

Permalink
Merge pull request #26 from Felixoid/relocating
Browse files Browse the repository at this point in the history
Moving the project to another scope
  • Loading branch information
Felixoid authored Dec 19, 2024
2 parents 3e12559 + f418ef5 commit 688d71f
Show file tree
Hide file tree
Showing 13 changed files with 311 additions and 223 deletions.
120 changes: 71 additions & 49 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,90 @@
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
#
# ******** 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 Advanced"

on:
push:
branches: [master]
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches: [ "master" ]
schedule:
- cron: '15 15 * * 6'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
name: Analyze (${{ matrix.language }})
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners (GitHub.com only)
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
runs-on: 'ubuntu-latest'
permissions:
# required for all workflows
security-events: write

# required to fetch internal or private CodeQL packs
packages: read

# only required for workflows in private repositories
actions: read
contents: read

strategy:
fail-fast: false
matrix:
# Override automatic language detection by changing the below list
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
language: ['go']
# Learn more...
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection

include:
- language: go
build-mode: autobuild
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
# Use `c-cpp` to analyze code written in C, C++ or both
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@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@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
- name: Checkout repository
uses: actions/checkout@v4

# ✏️ 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
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
# 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.

#- run: |
# make bootstrap
# make release
# For more 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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
# If the analyze step fails for one of the languages you are analyzing with
# "We were unable to automatically build your code", modify the matrix above
# to set the build mode to "manual" for that language. Then modify this step
# to build your code.
# ℹ️ 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: matrix.build-mode == 'manual'
shell: bash
run: |
echo 'If you are using a "manual" build mode for one or more of the' \
'languages you are analyzing, replace this with the commands to build' \
'your code, for example:'
echo ' make bootstrap'
echo ' make release'
exit 1
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
47 changes: 47 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Upload Docker images to ghcr.io
on:
release:
types: [published]
workflow_dispatch:
inputs:
ref:
description: 'Git tag to push the image'
required: true
type: string
jobs:
docker:
name: Build image
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
context: ${{ inputs.ref && 'git' || 'workflow' }}
images: ghcr.io/${{ github.repository }}
# create latest tag for branch events
flavor: |
latest=${{ inputs.ref && 'false' || 'auto' }}
tags: |
type=semver,pattern={{version}},value=${{inputs.ref}}
type=semver,pattern={{major}}.{{minor}},value=${{inputs.ref}}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{inputs.ref}}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
# push for non-pr events
push: ${{ github.event_name != 'pull_request' }}
context: .
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
37 changes: 19 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
name: Tests

on:
"on":
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:

Expand All @@ -14,24 +15,24 @@ jobs:
strategy:
matrix:
go:
- ^1.15
- ^1.16
- ^1.17
- ^1.21
- ^1.22
- ^1.23
- ^1
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Check out code into the Go module directory
uses: actions/checkout@v4

- name: Test
run: make test
- name: Test
run: make test

- name: Build and run version
run: |
make VERSION=testing-version
./graphite-ch-optimizer --version
- name: Build and run version
run: |
make VERSION=testing-version
./graphite-ch-optimizer --version
85 changes: 28 additions & 57 deletions .github/workflows/upload-assets.yml
Original file line number Diff line number Diff line change
@@ -1,80 +1,51 @@
---
name: Upload Packages to new release

on:
'on':
release:
types:
- published
workflow_dispatch:
inputs:
ref:
description: 'Git tag to push the image'
required: true
type: string

jobs:
build:
name: Build
runs-on: ubuntu-latest

container:
image: innogames/graphite-ch-optimizer:builder

outputs:
deb: ${{ steps.build.outputs.deb }}
rpm: ${{ steps.build.outputs.rpm }}
sha256sum: ${{ steps.build.outputs.sha256sum }}
md5sum: ${{ steps.build.outputs.md5sum }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
name: Checkout
with:
# Otherwise there's a risk to not get latest tag
# We hope, that the current commit at
# least 50 commits close to the latest release
fetch-depth: 50
# least 100 commits close to the latest release
fetch-depth: 100
fetch-tags: ${{ inputs.ref != '' }}
ref: ${{ inputs.ref }}
- name: Set up Go 1
uses: actions/setup-go@v5
with:
go-version: ^1
- name: Build packages
id: build
run: |
# Checkout action doesn't fetch tags
git fetch --tags
go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.40.0
make -e CGO_ENABLED=0 packages
make github_artifact
- name: Upload rpm
id: upload-rpm
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ steps.build.outputs.rpm }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifact/${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload sha256sum
id: upload-sha256sum
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ steps.build.outputs.sha256sum }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifact/${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload md5sum
id: upload-md5sum
uses: actions/upload-release-asset@v1
- name: Upload release assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ steps.build.outputs.md5sum }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifact/${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
- name: Upload deb
id: upload-deb
uses: actions/upload-release-asset@v1
run: |
TAG="${{ inputs.ref && inputs.ref || github.event.release.tag_name }}"
gh release upload --clobber --repo ${{ github.repository }} "$TAG" \
out/*.deb out/*.rpm out/*sum
- name: Upload packages to packagecloud.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ASSET: ${{ steps.build.outputs.deb }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: artifact/${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream
PACKAGECLOUD_TOKEN: ${{ secrets.PACKAGECLOUD_TOKEN }}
run: |
go install github.com/mlafeldt/pkgcloud/cmd/pkgcloud-push@e79e9efc
make packagecloud-stable
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
graphite-ch-optimizer
build/
out/
artifact/
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Image which contains the binary artefacts
#
FROM golang:alpine AS builder

ENV GOPATH=/go

RUN apk add make git --no-cache

WORKDIR /go/src/github.com/go-graphite/graphite-ch-optimizer
COPY . .
RUN make -e CGO_ENABLED=0 build

#
# Application image
#
FROM alpine:latest

RUN apk --no-cache add ca-certificates tzdata && mkdir /graphite-ch-optimizer

WORKDIR /graphite-ch-optimizer

COPY --from=builder \
/go/src/github.com/go-graphite/graphite-ch-optimizer/graphite-ch-optimizer \
/go/src/github.com/go-graphite/graphite-ch-optimizer/LICENSE \
.

ENTRYPOINT ["./graphite-ch-optimizer"]
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 InnoGames GmbH
Copyright (c) 2019-2024 InnoGames GmbH
Copyright (c) 2024 go-graphite

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit 688d71f

Please sign in to comment.