Fix issue #15
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Unit-Tests | |
on: | |
push: | |
branches: | |
- main | |
- local-storage-github-action | |
pull_request: | |
jobs: | |
test: | |
strategy: | |
matrix: | |
go: ['1.20'] | |
job_name: ['linux'] | |
# job_name: ['linux', 'windows'] | |
include: | |
- job_name: linux | |
os: ubuntu-latest | |
containerName: 'test-cnt-ubn' | |
# - job_name: windows | |
# os: windows-latest | |
# containerName: 'test-cnt-win' | |
# cgo: '0' | |
name: Build and Test on | |
runs-on: ${{ matrix.os }} | |
env: | |
AWS_ENDPOINT: http://localhost:4566 | |
AWS_REGION: us-east-1 | |
AWS_ACCESS_KEY_ID: test | |
AWS_SECRET_ACCESS_KEY: test | |
AWS_BUCKET_NAME: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ matrix.go }} | |
check-latest: true | |
- run: go version | |
- name: Set CGO | |
shell: bash | |
run: | | |
if [[ "${{ matrix.cgo }}" != "" ]]; then echo 'CGO_ENABLED=${{ matrix.cgo }}' >> $GITHUB_ENV ; fi | |
- name: Install libfuse on Linux | |
shell: bash | |
run: | | |
sudo apt-get install fuse3 libfuse-dev rpm pkg-config | |
if: matrix.os == 'ubuntu-latest' | |
- name: Go module cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Build | |
run: | | |
./build.sh | |
- name: Create Azure Configuration File on Linux | |
run: |- | |
cnfFile=$HOME/azuretest.json | |
echo $cnfFile | |
touch $cnfFile | |
echo "{" > $cnfFile | |
echo "\"block-acct\"": "\"${{ secrets.AZTEST_BLOCK_ACC_NAME }}\"", >> $cnfFile | |
echo "\"adls-acct\"": "\"${{ secrets.AZTEST_ADLS_ACC_NAME }}\"", >> $cnfFile | |
echo "\"block-cont\"": "\"${{ matrix.containerName }}\"", >> $cnfFile | |
echo "\"adls-cont\"": "\"${{ matrix.containerName }}\"", >> $cnfFile | |
echo "\"block-key\"": "\"${{ secrets.AZTEST_BLOCK_KEY }}\"", >> $cnfFile | |
echo "\"adls-key\"": "\"${{ secrets.AZTEST_ADLS_KEY }}\"", >> $cnfFile | |
echo "\"block-sas\"": "\"${{ secrets.AZTEST_BLOCK_SAS }}\"", >> $cnfFile | |
echo "\"block-cont-sas-ubn-18\"": "\"${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_18 }}\"", >> $cnfFile | |
echo "\"block-cont-sas-ubn-20\"": "\"${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_20 }}\"", >> $cnfFile | |
echo "\"adls-sas\"": "\"${{ secrets.AZTEST_ADLS_SAS }}\"", >> $cnfFile | |
echo "\"msi-appid\"": "\"${{ secrets.AZTEST_APP_ID }}\"", >> $cnfFile | |
echo "\"msi-resid\"": "\"${{ secrets.AZTEST_RES_ID }}\"", >> $cnfFile | |
echo "\"msi-objid\"": "\"${{ secrets.AZTEST_OBJ_ID }}\"", >> $cnfFile | |
echo "\"spn-client\"": "\"${{ secrets.AZTEST_CLIENT }}\"", >> $cnfFile | |
echo "\"spn-tenant\"": "\"${{ secrets.AZTEST_TENANT }}\"", >> $cnfFile | |
echo "\"spn-secret\"": "\"${{ secrets.AZTEST_SECRET }}\"", >> $cnfFile | |
echo "\"skip-msi\"": "true", >> $cnfFile | |
echo "\"proxy-address\"": "\"\"" >> $cnfFile | |
echo "}" >> $cnfFile | |
if: matrix.os == 'ubuntu-latest' | |
- name: Create Azure Configuration File on Windows | |
run: |- | |
$cnfFile="~\azuretest.json" | |
Write-Host $cnfFile | |
$content = @" | |
{ | |
"block-acct": "${{ secrets.AZTEST_BLOCK_ACC_NAME }}", | |
"adls-acct": "${{ secrets.AZTEST_ADLS_ACC_NAME }}", | |
"block-cont": "${{ matrix.containerName }}", | |
"adls-cont": "${{ matrix.containerName }}", | |
"block-key": "${{ secrets.AZTEST_BLOCK_KEY }}", | |
"adls-key": "${{ secrets.AZTEST_ADLS_KEY }}", | |
"block-sas": "${{ secrets.AZTEST_BLOCK_SAS }}", | |
"block-cont-sas-ubn-18": "${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_18 }}", | |
"block-cont-sas-ubn-20": "${{ secrets.AZTEST_BLOCK_CONT_SAS_UBN_20 }}", | |
"adls-sas": "${{ secrets.AZTEST_ADLS_SAS }}", | |
"msi-appid": "${{ secrets.AZTEST_APP_ID }}", | |
"msi-resid": "${{ secrets.AZTEST_RES_ID }}", | |
"msi-objid": "${{ secrets.AZTEST_OBJ_ID }}", | |
"spn-client": "${{ secrets.AZTEST_CLIENT }}", | |
"spn-tenant": "${{ secrets.AZTEST_TENANT }}", | |
"spn-secret": "${{ secrets.AZTEST_SECRET }}", | |
"skip-msi": true, | |
"proxy-address": "" | |
} | |
"@ | |
$content | Out-File -FilePath $cnfFile -Encoding Ascii | |
shell: powershell | |
if: matrix.os == 'windows-latest' | |
- name: Create S3 Configuration File on Linux | |
run: |- | |
cnfFile=$HOME/s3test.json | |
echo $cnfFile | |
touch $cnfFile | |
echo "{" > $cnfFile | |
echo "\"bucket-name\"": "\"${{ env.AWS_BUCKET_NAME }}\"", >> $cnfFile | |
echo "\"access-key\"": "\"${{ env.AWS_ACCESS_KEY_ID }}\"", >> $cnfFile | |
echo "\"secret-key\"": "\"${{ env.AWS_SECRET_ACCESS_KEY }}\"", >> $cnfFile | |
echo "\"endpoint\"": "\"${{ env.AWS_ENDPOINT }}\"", >> $cnfFile | |
echo "\"region\"": "\"${{ env.AWS_REGION }}\"", >> $cnfFile | |
echo "\"use-path-style\"": "\"true\"" >> $cnfFile | |
echo "}" >> $cnfFile | |
if: matrix.os == 'ubuntu-latest' | |
- name: Create S3 Configuration File on Windows | |
run: |- | |
$cnfFile="~\s3test.json" | |
Write-Host $cnfFile | |
$content = @" | |
{ | |
"bucket-name": "${{ env.AWS_BUCKET_NAME }}", | |
"access-key": "${{ env.AWS_ACCESS_KEY_ID }}", | |
"secret-key": "${{ env.AWS_SECRET_ACCESS_KEY }}", | |
"endpoint": "${{ env.AWS_ENDPOINT }}", | |
"region": "${{ env.AWS_REGION }}", | |
"use-path-style": true | |
} | |
"@ | |
$content | Out-File -FilePath $cnfFile -Encoding Ascii | |
shell: powershell | |
if: matrix.os == 'windows-latest' | |
- name: Start LocalStack | |
run: | | |
pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal | |
docker pull localstack/localstack # Make sure to pull the latest version of the image | |
localstack start -d # Start LocalStack in the background | |
echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container | |
localstack wait -t 30 # to become ready before timing out | |
echo "Startup complete" | |
- name: Run some Tests against LocalStack | |
run: | | |
awslocal s3 mb s3://test | |
awslocal s3 ls | |
- name: Run unit tests | |
run: go test -v -timeout=2h ./... --tags=unittest | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
env: | |
go: '1.20' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.go }} | |
check-latest: true | |
- run: go version | |
- name: Set CGO | |
shell: bash | |
run: | | |
if [[ "${{ env.go }}" != "" ]]; then echo 'CGO_ENABLED=${{ env.go }}' >> $GITHUB_ENV ; fi | |
- name: Install libfuse on Linux | |
shell: bash | |
run: | | |
sudo apt-get install libfuse-dev | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
# Require: The version of golangci-lint to use. | |
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version. | |
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit. | |
version: latest | |
# Optional: golangci-lint command line arguments. | |
args: --tests=false --timeout=5m --skip-dirs test,common/stats_collector,common/stats_monitor --skip-files component/libfuse/libfuse2_handler_test_wrapper.go --out-format=github-actions | |
- name: Notice file check | |
run: | | |
./notices_fix.sh | |
result=$(git diff NOTICE | wc -l) | |
if [ $result -ne 0 ]; then | |
echo "Notices needs a fix. Run ./notices_fix.sh and commit NOTICE file." | |
exit 1 | |
else | |
echo "Notices are up to date." | |
fi |